1. Variable assignment:NAME=LBG equals sign cannot have spaces name= "Lebron James" variable values have spaces in double quotes Echo ${name} with ${} More insurance shopt-s-O Nou Nset setting "Declare and use first"
2. Cancel the variable:unset releasing memory for variables and functions
3. Position parameters:${N}: Input nth parameter ($ = script name) $#: number of input parameters [email protected]: input all parameters $!: The last parameter of the input $?: The return value of the previous command (used in the script to convict The execution state of the previous command, any return that is not 0 indicates an abnormal execution)
4. Arrays:Declare-a array= (' ladawn ' LBG ' LBJ ')
5. Read-only variables:Declare-r n=10 readonly n=10
6. Variables in the function:If you do not declare local, the variable in the function is also a global variable. If declared as local (local var=200), the scope of the variable is only within the function.
7. References:Double quotes: Weak references, special symbols ($, \, ') still resolve to special meanings. Single quote: Strong reference, all characters are literal meaning, no longer have special meaning.
8. Command replacement:a=$ (data) or a= ' data ' means that the output of the data command is taken out and assigned to a
9.BC Operation:Used for floating point calculation output. Used by pipelines. Tatal=$ (echo "34/15" | BC)
9. Numerical Operation:Let "sum+=1" means sum = sum+1 let "j=sum%2" means j = sum% 2
Shell programming------variables, assignments, and operations