1、let 算术运算表达式
let C=$A+$B
eg: A=3 B=5 let C=$A+$B
echo $C
[[email protected] test]# A=3
[[email protected] test]# B=3
[[email protected] test]# let C=$A+$B
[[email protected] test]# echo $C
6
2、$[算术运算表达式]
C=$[$A+$B]
eg: A=2 B=6 C=$[$A+$B]
echo $C
[[email protected] test]# A=2
[[email protected] test]# B=6
[[email protected] test]# C=$[$A+$B]
[[email protected] test]# echo $C
8
3、$((算术运算表达式))
C=$(($A+$B))
eg: A=6 B=7 C=$(($A+$B))
echo $C
[[email protected] test]# A=6
[[email protected] test]# B=7
[[email protected] test]# C=$(($A+$B))
[[email protected] test]# echo $C
13
4、expr 算术运算表达式,表达式中各操作数及运算符之间要有空格,而且要使用命令引用
C=`expr $A + $B`
eg: A=5 B=6 C=`expr $A + $B`
echo $C
[[email protected] test]# A=5
[[email protected] test]# B=6
[[email protected] test]# C=`expr $A + $B`
[[email protected] test]# echo $C
11