こんにちは。
$((arithmetic expression))
の記法は、Bash に限らず動くようです1:
$ dash -c 'x=1; echo $((x + 1))'
2
またこちらの方が、expr
コマンドを使うよりも、推奨のようです:
$ echo "expr 1 + 1" | shellcheck -s sh -
In - line 1:
expr 1 + 1
^--^ SC2003 (style): expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].
-
"Comparison of command shells" (Wikipedia) ↩