首页 > 系统服务 > 详细

shell 中简单的运算

时间:2017-01-10 22:39:53      阅读:249      评论:0      收藏:0      [点我收藏+]


命令介绍


 1、expr 命令


[root@localhost shell]# a=1

[root@localhost shell]# b=2


[root@localhost shell]# expr $a + $b 

3


[root@localhost shell]# expr $a - $b

-1


[root@localhost shell]# expr $a \* $b

2


[root@localhost shell]# expr $b / $a

2


 2、let 命令 


[root@localhost shell]# c=4

[root@localhost shell]# let d=c+4

[root@localhost shell]# echo $d

8


3、内置命令 双括号

[root@localhost shell]# echo $((1+7)) ##不支持小数计算


[root@localhost shell]# echo $[7+8]

15



本文出自 “sdsca” 博客,请务必保留此出处http://sdsca.blog.51cto.com/10852974/1890831

shell 中简单的运算

原文:http://sdsca.blog.51cto.com/10852974/1890831

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!