Friday, June 22, 2007

Double brackets for arithmetic operation


Suppose we have to increment the value of a variable

Normal way:
$ a=10; a=`expr $a + 2` ; echo $a
12

Can also be done this way:
$ a=10; ((a=a+2)); echo $a
12

1 comment:

ptankov said...

Or even:
a=10; ((a+=2)); echo $a

© Jadu Saikia www.UNIXCL.com