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