LoginSignup
0
0

$((算術式)) (シェル)

Last updated at Posted at 2019-09-27

こんにちは。
$((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 [[ ]].
  1. "Comparison of command shells" (Wikipedia)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0