1. shell variables are defined default character type as the variable value with no spaces, may be used without ""
2. shell in back quotes `` role:. "Generally within the command to be executed into anti quotes, commonly used in the"
echo "Today IS` date` "echo" Today DATE IS "DATE absence of anti-quotation marks, will are treated as characters run.
echo "Today iS (DATE)"
Note: command anti-quotes execution is performed in the sub-shell, such as calling a function in the anti-quotes, the function used in the variable can not get to in the current shell
3. read parameters: -p for setting message; -t number waiting for setting the countdown; -n number taken to set several parameters;
When the transport spaces read input values v1 v2 v3 to separate the three values: read can define multiple variables
4. Use of the line editor: free -m | grep '^ Mem:' | awk '{print $ 1}'
5. shell variables are defined in the default character type, then how do arithmetic it?
1. You can use the expr command; pay attention and distinguish export, export is used to define global variables !!!!
example: n1 = 10; n2 = 20; echo `expr $ n1 + must have around $ n2` # pay attention to operational sign space
2. echo $ (($ n1 \ * $ n2)) # * have a special meaning, need to escape doing arithmetic
3. let n1 ++
4. Use bc calculator: echo "2 + 4" | bc
6. i ++ and ++ i difference:
i ++ is first referenced, and then accumulate;
++ i is first accumulated, then the referenced;