Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the difference between the following two shell arithmetic commands:

echo $[ $var1 - 1 ]
echo $(( $var1 - 1 ))

Assuming var1 = 5 for example.

share|improve this question
In neither case you need the sigil, just echo $[ var1 - 1 ] and echo $(( var1 - 1 )) is enough. – manatwork Mar 6 '13 at 7:01
up vote 4 down vote accepted

From man bash:

Arithmetic Expansion
   Arithmetic expansion allows the evaluation of an arithmetic 
   expression and the substitution of the result.  The format 
   for arithmetic expansion is:


   The old format $[expression] is deprecated and will be 
   removed in upcoming versions of bash.
share|improve this answer
You beat me to the answer while I was looking for this manpage snippet. – jordanm Mar 5 '13 at 21:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.