declare声明变量类型
数值运算
方法一:
[root@localhost ~]# a=1
[root@localhost ~]# b=2
[root@localhost ~]# declare -i c=$a+$b
方法二:
[root@localhost ~]# a=1
[root@localhost ~]# b=2
[root@localhost ~]# c=$(expr $a + $b)
#注意“+”号两侧必须有空格
方法三:
[root@localhost ~]# a=1
[root@localhost ~]# b=2
[root@localhost ~]# c=$(( $a + $b ))
#或者使用[],推荐使用(())
[root@localhost ~]# c=$[ $a + $b ]