arithmetic expansion

Evaluating whole-number maths inside $(( )) and replacing it with the result; (( )) on its own evaluates without printing anything.

In more detail

Variables inside do not need a dollar sign, and the usual operators work, including % for remainder and ++ to add one. The bare (( )) form returns success when the result is non-zero, so it doubles as a numeric test in if and while. Only integers are supported; use bc for decimals.

Examples

n=$(( n + 1 ))
(( count++ ))

Related terms

Taught in

References