Ravi Sir's Cards › AWS
Bash maths
This revision card explains Bash maths. It starts from the need that integers with $(( )). It describes compare with (( )). The how-to section notes decimals need bc. An example on the card is exit code in $?
Read card text
What this card says
Why do we need it?
Integers with $(( )).
echo $((a+b))
What is it?
Compare with (( )).
(( n > 5 ))
How to do it
Decimals need bc.
echo 'scale=2;10/3' | bc
Example
Exit code in $?.
echo $?