3

Possible Duplicate:
bash: $[<arithmetic-expression>] vs. $((<arithmetic-expression>))

The $(( expr )) construct can be used for integer math in bash, e.g.

echo $(( 2*2 + 1 )) # 5

$[ expr ] seems to do to do the same (but isn't documented):

echo $[ 2*2 + 1 ] # 5

Are these constructs equivalent in bash?

Community
  • 1
  • 1
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378

1 Answers1

4

man bash says:

The format for arithmetic expansion is:

        $((expression))

The old format $[expression] is deprecated and will be removed in upcoming versions of bash.

hmakholm left over Monica
  • 23,074
  • 3
  • 51
  • 73
  • 1
    Just FYI, the man page doesn't say this anyone according to a search for `$[` and other phrases in this. – Kevin Cox Sep 25 '13 at 14:27