![两种shell算法的区别](https://linux22.com/image/29691/%E4%B8%A4%E7%A7%8Dshell%E7%AE%97%E6%B3%95%E7%9A%84%E5%8C%BA%E5%88%AB.png)
下面两个shell算术命令有什么区别:
echo $[ $var1 - 1 ]
echo $(( $var1 - 1 ))
例如,假设 var1 = 5。
答案1
来自 man bash:
Arithmetic Expansion
Arithmetic expansion allows the evaluation of an arithmetic
expression and the substitution of the result. The format
for arithmetic expansion is:
$((expression))
The old format $[expression] is deprecated and will be
removed in upcoming versions of bash.