Arithmetic
Use $(( )) for integer math: + - * / % and **. let and (( )) change variables. bc handles decimals.
Example
a=17; b=5
echo $((a + b)) $((a / b)) $((a % b)) $((2 ** 10))
((a++))
echo $a
let "b *= 2"
echo $b
echo "scale=2; 17 / 5" | bcResult
22 3 2 1024 18 10 3.40
Exercise
Integer math syntax.
echo $(1 + 2))
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.