Variables and Arguments
Variables
name="Aamnah"
$name="Aamnah"
There is NO whitespace before or after =
. $name="Aamnah"
will work but the preferred syntax is not including $ sign when you are defining a variable. You should use the $ sign when you are calling the variable and NOT when you’re defining it.
Referencing variables:
echo $name
echo ${name}
${name}
is preferred syntax.
Arguments
Arguments are keywords that are passed in the command line when executing the bash script/command.
./script.sh foo bar
$0, $1, $2 etc..
$0
is the name of the script, $1
is the first argument, $2
is the second argument and so on.