$(( )) arithmetic
Try it yourself →Performs math operations.
Syntax
$(( expression ))
Description
Bash works with text by default; $(( )) is used for numeric operations. + - * / % are supported.
Example
echo $((3 + 4)) echo $((7 % 2)) echo $((2 * 5))
Expected output
7 1 10
When to use?
Counter, calculation.
Common mistakes
- ⚠️ Outside $(( )) 3 + 4 remains as text; required for arithmetic.