expr 计算整数变量值
使用方法如下:
linux-zpycfm:/home/test/shell # s=expr +
-bash: +: command not found
linux-zpycfm:/home/test/shell # s=expr +
-bash: +: command not found
linux-zpycfm:/home/test/shell # s=`expr + `
linux-zpycfm:/home/test/shell # echo $s linux-zpycfm:/home/test/shell # `expr + `
-bash: : command not found
linux-zpycfm:/home/test/shell # expr + linux-zpycfm:/home/test/shell # expr +
+
linux-zpycfm:/home/test/shell # expr $s *
expr: syntax error
linux-zpycfm:/home/test/shell # expr $s \* linux-zpycfm:/home/test/shell # expr `expr + ` \* linux-zpycfm:/home/test/shell # expr "*" linux-zpycfm:/home/test/shell # expr '*' linux-zpycfm:/home/test/shell # expr *
expr: syntax error
linux-zpycfm:/home/test/shell # expr 2.3 + 3.4
expr: non-integer argument
运算符号和参数之间要有空格分开;
通配符号(*),在作为乘法运算符时要用\、“”、‘’符号修饰
–:expr 3 \* 2 expr 3 “*” 2 expr 3 ‘*’ 2
`(反引号)与键盘上的~同一个键上的符号