『总结』shell算数运算方法
时间:2015-05-11 03:51 来源:linux.it.net.cn 作者:IT
1.expr 表达式
expr只能用于一元操作符,不支持二元操作符
1
2
x=1
x=$(expr $x + 1)
$x + 1之间必须有空格
2.let 表达式
1
2
3
4
x=10
let x=$x+1
let x+=1
let x*=10
3.使用$((表达式))
1
x=$((4+5))
4.使用$[ ]形式
1
x=$[ 4 + 5 ]
5.使用decalare
1
2
3
decare -i num
num=$num+1
echo $num
(责任编辑:IT)
1.expr 表达式
$x + 1之间必须有空格 2.let 表达式
3.使用$((表达式))
4.使用$[ ]形式
5.使用decalare
(责任编辑:IT) |