Arithmetic Expansion An arithmetic expression enclosed in double parentheses pre- ceded by a dollar sign ( $((arithmetic-expression)) ) is replaced by the value of the arithmetic expression within the double parenthesis. Arithmetic expansion provides a mechanism for evaluating an arithmetic expression and sub- stituting its value. The format for arithmetic expansion is as follows: $((expression)) The expression is treated as if it were in double-quotes, except that a double-quote inside the expression is not treated specially. The shell will expand all tokens in the expression for parameter expansion, command substitution and quote removal. Next, the shell will treat this as an arithmetic expression and substitute the value of the expression. The arithmetic expression will be processed according to the rules of the ISO C with the following exceptions: o Only integer arithmetic is required. o The sizeof() operator and the prefix and postfix ++ and -- operators are not required. o Selection, iteration and jump statements are not sup- ported. As an extension, the shell may recognize arithmetic expres- sions beyond those listed. If the expression is invalid, the expansion will fail and the shell will write a message to standard error indicating the failure. A simple example using arithmetic expansion: # repeat a command 100 times x=100 while [ $x -gt 0 ] do command x=$(($x-1)) done ---------------------------- Since many of the arithmetic operators require quoting, an alternative form of the let command is provided. For any command which begins with a ((, all the characters until a matching )) are treated as a quoted expression. More pre- cisely, ((...)) is equivalent to let "...".