Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top