Well, having the arithmetic command ((...)) -- not to be confused with
arithmetic expansion $((...)) -- means that you can reduce your use
of expr considerably, without losing compatibility with ksh. (In the
short term, of course, you would lose compatibility with many Linux
installations.)
Instead of the rather ugly
a=`expr $a + 1`
you can do
((a+=1))
Actually, you can accomplish something close with the older bash,
although it's not quite so tidy:
: $((a+=1))
The difference between the arithmetic command and arithmetic expansion
(for those readers who aren't already familiar with it) is that the
arithmetic command is indeed a command, which can stand by itself, whereas
arithmetic expansion is an action taken by the shell, which replaces the
part of the current command line occupied by the $((...)) construct with
the result of evaluating the expression inside. For example:
bash-2.00$ a=2
bash-2.00$ b=3
bash-2.00$ echo xxx$(( a + b ))yyy
xxx5yyy
bash-2.00$
Note that shell variables inside either ((...)) or $((...)) don't need a
dollar sign.
-- ted@psg.com http://psg.com/~ted/ (Ted Powell) Promote Responsible Net Commerce: Fight Spam! http://spam.abuse.net/