Skip to content
Justice Tech School

Arithmetic

Use $(( )) for integer maths. Bash has no floats, use bc or awk for decimals.

Example
a=7; b=2
echo $((a + b)) $((a / b)) $((a % b)) $((a ** 3))
((a++))
echo $a
echo "scale=2; 7/2" | bc

Result

9 3 1 343
8
3.50

Exercise

Integer math.

echo $((a  b))

Quiz Test

Does Bash do float math?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.