Is $(( expr )) equivalent to $[ expr ] in bash? [duplicate]
-
23-12-2020 - |
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?
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