linux shell中数值变量的递增

 

001、使用let

[root@PC1 test2]# ls
[root@PC1 test2]# a=10
[root@PC1 test2]# echo $a
10
[root@PC1 test2]# let a=$a+5     ## 使用let对数值变量进行修改
[root@PC1 test2]# echo $a
15

image

 

002、使用(())

[root@PC1 test2]# ls
[root@PC1 test2]# a=100
[root@PC1 test2]# echo $a
100
[root@PC1 test2]# a=$((a+30))     ## 使用(())对数值变量进行修改
[root@PC1 test2]# echo $a
130

image

 。

 

posted @ 2025-11-21 09:45  小鲨鱼2018  阅读(4)  评论(0)    收藏  举报