Arithmetic from the command line
$ echo $((1+1))
Outputs 2 of course.
Another way is with,
$ echo $[1+1]
Or if you want to use decimals in your math calculations as bash only does integer math, you can use the bc command.
$ echo "2.5 + 3.6" | bc
and that will give you 6.1, but if you try to use 2.5+3.6 it will just error.
[Click to add or edit comments])
Please prepend comments below including a date