Variables
Appearance
General
- all variables are considered strings, even numbers
- create a variable by using it
- assign a variable without the $, use it with the $
- salutation=Hello
- echo $salutation
- Do not use spaces on either side of the equal sign
- Double quote strings with spaces
Assigning User Input to a Variable
- Use read <variable name>
- user enters the value
- echo $<variable name>
Special Variables
- $0 = name of the shell script
- $# = number of parameters passed
- $$ = pid of the shell script
- $* = list of all parameters in a single variable
- $@ = list of all parameters in a single variable but doesn't use IFS environmental variable
- $1 = first parameter
Quoting a Variable Name
blah=douche echo "$blah" => douche echo '$blah => $blah