linux系统中let命令


1、linux系统中let命令在bash中用于计算,变量名前不用加$,可以实现自加和自减操作

 简单用法

[root@linuxprobe test]# a=3 [root@linuxprobe test]# echo $a 3 [root@linuxprobe test]# b=a+4 [root@linuxprobe test]# echo $b a+4 [root@linuxprobe test]# let b=a+4 ## let可以实现变量前不加$的计算 [root@linuxprobe test]# echo $b 7

 

2、自加、自减操作

[root@linuxprobe test]# a=3 [root@linuxprobe test]# echo $a 3 [root@linuxprobe test]# let a+=10 ## 自加操作 [root@linuxprobe test]# echo $a 13 [root@linuxprobe test]# let a-=20 ##自减操作 [root@linuxprobe test]# echo $a -7

 

3、let a++、a--

[root@linuxprobe test]# a=5;for i in `seq 10`;do echo -n "";let a++;done ##自加操作 [root@linuxprobe test]# echo $a 15 [root@linuxprobe test]# a=5;for i in `seq 20`;do echo -n "";let a--;done ##自减操作 [root@linuxprobe test]# echo $a -15

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM