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

Tony Arnold tony.arnold at manchester.ac.uk
Tue Dec 4 11:55:23 UTC 2012


Johnny,

On 03/12/12 19:14, Johnny Rosenberg wrote:

>> On Mo, 2012-12-03 at 18:02 +0100, Johnny Rosenberg wrote:
>>> ~$ a=3
>>> ~$ b=4
>>> ~$ echo $(($a+$b))

As an aside, you don't need the $ symbols to indicate variables inside
the (( )). So the following works too:

echo $((a+b))

This also works using [] thus

echo $[a+b]

Regards,
Tony.--
Tony Arnold,                        Tel: +44 (0) 161 275 6093
Head of IT Security,                Fax: +44 (0) 705 344 3082
University of Manchester,           Mob: +44 (0) 773 330 0039
Manchester M13 9PL.                 Email: tony.arnold at manchester.ac.uk




More information about the ubuntu-users mailing list