Shell脚本(二)数学运算
2017-07-22 21:32
423 查看
直接上代码。
#!/bin/bash no1=4 no2=5 echo "using let ..." let result=no1+no2 echo "result is: ${result}" let result++ echo "result after 1 increment is: ${result}" let result+=6 echo "result after 6 increment is: ${result}" echo "using []..." result=$[ no1 + no2 ] echo "result is: ${result}" echo "using (())..." result=$(( no1 + no2 + 1 )) echo "result is: ${result}" echo "using expr ..." result=$( expr $no1 + $no2 + 2 ) echo "result is: ${result}" # ``等价于$() echo "using \`\` ..." result=`expr $no1 + $no2 + 3` echo "result is: ${result}"
相关文章推荐
- Shell脚本编程中常用的数学运算实例
- shell脚本中的数学运算
- shell脚本数组元素的数学运算
- Shell脚本基础10-基本的数学运算
- SHELL脚本 数学运算、数组、文本处理
- Shell脚本攻略03-使用shell进行数学运算
- SHELL脚本--数学运算和bc命令
- shell脚本中的数学运算
- Shell脚本编程中常用的数学运算实例
- Shell脚本编程中常用的数学运算实例
- shell脚本浮点数,整数运算;for循环1加到100;Ubuntu12.04LTS 启动界面添加root登录;查找截取循环求和
- Linux学习4之shell脚本中的小数运算
- shell变量数学运算
- shell命令-bc(数学运算/进制转换)
- 数值运算shell脚本
- Shell脚本[运算表达式,条件控制语句]
- Shell编程——Shell中的数学运算
- shell中数学运算
- shell 执行数学运算
- Shell实现的一些数学运算自定义函数分享