shell中中括号实现变量运算

发布时间 2023-06-12 15:10:04作者: 小鲨鱼2018

 

001、

[root@PC1 test03]# a=100
[root@PC1 test03]# echo $a
100
[root@PC1 test03]# echo $a+500
100+500
[root@PC1 test03]# echo $[a+500]    ## 中括号可以实现变量运算
600
[root@PC1 test03]# echo $a*3
100*3
[root@PC1 test03]# echo $[a*3]
300
[root@PC1 test03]# b=$[a*500]        ## 变量赋值
[root@PC1 test03]# echo $b
50000