2つのシェルアルゴリズムの違い

2つのシェルアルゴリズムの違い

次の2つのシェル算術コマンドの違いは何ですか?

echo $[ $var1 - 1 ]
echo $(( $var1 - 1 ))

たとえば、var1 = 5 であるとします。

ベストアンサー1

メンズバッシュから:

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.

おすすめ記事