typeset can also implement calculations
[root@linhexiao shellTest]# typeset -i a=1 b=3 [root@linhexiao shellTest]# a=a+b [root@linhexiao shellTest]# echo $a 4 [root@linhexiao shellTest]# a=a*b [root@linhexiao shellTest]# echo $a 12
$[ ] can also be calculated
1) As long as the expression is legal, it can be calculated [root@linhexiao shellTest]# echo $[2+3] 5 [root@linhexiao shellTest]# echo $[2+ 3] 5 [root@linhexiao shellTest]# echo $[ 2+ 3] 5 2) $[] cannot calculate decimals [root@linhexiao shellTest]# echo $[ 2.2+ 3] bash: 2.2+ 3: syntax error: invalid arithmetic operator (error token is ".2+ 3") [root@linhexiao shellTest]# echo $[ 2+ 3] 5 [root@linhexiao shellTest]# echo $[ 2- 3] -1 [root@linhexiao shellTest]# echo $[ 2* 3] 6 [root@linhexiao shellTest]# echo $[ 2** 3] 8 [root@linhexiao shellTest]# echo $[ 2/ 3] 0