Re: Bash – $(( )) vs. $[]

Johnny Rosenberg gurus.knugum at gmail.com
Mon Dec 3 19:14:46 UTC 2012


2012/12/3 Oliver Grawert <ogra at ubuntu.com>:
> hi
> On Mo, 2012-12-03 at 18:02 +0100, Johnny Rosenberg wrote:
>> ~$ a=3
>> ~$ b=4
>> ~$ echo $(($a+$b))
>> 7
>> ~$ echo $[$a+$b]
>> 7
>> ~$
>>
>>
>> So are these syntaxes equivalent? If not, what are the differences?
>
> they are in bash, the $[] is bash specific style here.
>
> but they arent in POSIX compliant shells (like the system shell of
> ubuntu (dash))

Okay, I suspected that. I never use dash anyway, so I guess I'll
continue to use the bash specific style then. Thanks!


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ



>
>
> ogra at chromebook:~$ /bin/sh
> $ a=1
> $ b=2
> $ echo $[$a+$b]
> $[1+2]
> $ echo $(($a+$b))
> 3
> $
> ogra at chromebook:~$
>
> ciao
>         oli
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>




More information about the ubuntu-users mailing list