linux shell终端中实现数值计算

发布时间 2023-10-15 10:15:38作者: 小鲨鱼2018

 

001、方法1 expr

[root@pc1 test]# expr 50 + 40
90

 

 

002、方法2 bc

[root@pc1 test]# echo 50 + 40 | bc
90

 

003、方法3  awk

[root@pc1 test]# awk 'BEGIN{print 50 + 40}'
90

 

004、方法4  (())

[root@pc1 test]# echo $((50 + 40))
90
[root@pc1 test]# ((sum=50+40))
[root@pc1 test]# echo $sum
90

 

005、中括号

[root@pc1 test]# echo $[50+40]
90

 

006、let

[root@pc1 test]# let sum=50+48
[root@pc1 test]# echo $sum
98

 

007、