Does $((mathematical expression)) and $[mathematical expression] mean the same?
What does '$[mathematical expression]' do exactly?
[root@pn]# a=3
[root@pn]# b=2
[root@pn]# echo $[a-b]
1
[root@pn]# echo $((a-b))
1
Are they equivalent with regards to Arithmetic evaluation?
They are equivalent in bash but according to the man pages:
It's the first time I see this ...
$ bash -c 'echo $[ 2 + 3 ]'
5
$ zsh -c 'echo $[ 2 + 3 ]'
5
$ ksh93 -c 'echo $[ 2 + 3 ]'
$[ 2 + 3 ]
$ pdksh -c 'echo $[ 2 + 3 ]'
$[ 2 + 3 ]
---------- Post updated at 09:57 PM ---------- Previous update was at 09:56 PM ----------
What version of bash are you using?
3.2.39
Thank you, I cannot find this in the man pages of the bash version I'm currently using, but I found it in the zsh manual pages:
A minor nitpick. $((...)) does not necessarily imply a mathematical expression. The following is perfectly valid
echo $((echo hi);(echo there))
This example is included in the IEEE 1003.1-2008 rationale.