Variables Flashcards
how do you write a function?
name () {
commands
return
}
What is top down design?
Process of identifying top-level steps and developing increasing detailed views of those steps.
Shell functions are:
“Mini-scripts” located inside other scripts and can as as autonomous programs.
how do you start every script:
!/bin/bash
Run a script with what cmds:
./
How are variables written:
variable=value
a=z
Assign the string “z” to variable a.
b=”a string”
Embedded spaces must be within quotes
c=”a sting and $b”
Other expressions such variables can be expanded into a variable
d=”$(ls -l foo.txt)”
Variable is the result of the cmd
e=$((5 * 7))
Arithmetic expression
f=”\t\ta string\n”
Escape sequence such as tabs and new lines.
Variable result of: filename="myfile" #mv "$filename" "${filename}1"
myfile1
Quoting in variables:
Good practice to enclose variables and cmd substitutions in double quotes to limit the effects of word-splitting by the shell.