linux shell中数值变量的递加

 

001、let

[root@pc1 test1]# a=1
[root@pc1 test1]# echo $a
1
[root@pc1 test1]# let a=$a+50     ## 数值变量递加
[root@pc1 test1]# echo $a
51

 

002、使用括号(())

[root@pc1 test1]# a=1
[root@pc1 test1]# echo $a
1
[root@pc1 test1]# a=$((a+50))      ## 使用括号递加
[root@pc1 test1]# echo $a
51

 。

 

posted @ 2024-02-19 10:26  小鲨鱼2018  阅读(26)  评论(0编辑  收藏  举报