expr使用
- 算表达式的使用
-bash-4.1$ count=1 -bash-4.1$ num=2 -bash-4.1$ echo `expr $count + $num` 3 -bash-4.1$ echo $[${count} + ${num}] 3 -bash-4.1$ echo $((${count} + ${num})) 3 -bash-4.1$ echo $[${count} + 1] 2 -bash-4.1$
补充:变量名外面的花括号是可选的,加不加都行,加花括号是为了帮助解释器识别变量的边界,例如echo "I am good at ${skill}Script",如果不加花括号解释器就会把$skillScript当成一个变量