First page Back Continue Last page Graphics
Arithmetic
Arithmetic is normally done with the let command:
declare -i x=0
let "x = x + 1"
let x=$x+1
let x+=1
You can enclose an arithmetic expression in (( ... )) as well, or in $[ ... ] or $(( ... )) to have the value returned.
For example, these are the same. In each case, the x variable now holds the value that was displayed:
((x=x+1)); echo $x
echo $((x=x+1))
echo $[x=x+1]