The double-parentheses construct (( … ))
The (( … )) construct permits arithmetic
expansion and evaluation. In its simplest form,
a=$(( 5 + 3 ))
would set a
to 5 + 3
, or 8
.
However, this double-parentheses construct is also
a mechanism for allowing C-style manipulation of
variables in Bash, for example, (( var++ ))
.
(( a = 23 ))
(( a++ ))
(( --a ))
(( t = a<45?7:11 )) # C-style trinary operator
echo $((0x9abc)) # double-parentheses arithmetic expansion/evaluation