I was wondering, is it possible to do simple maths in bash? I'm thinking something like, =25-5 would print out 20 or something.
Can this be done easily?
Just type "bc" no quote into the terminal. Then type all the math stuff in after that.
If we are really talking about Bash, not Bourne Shell (sh) or other shells, it's easy.
Bash can compute basic expressions with $((expression)) and here's an example on how you might like to use it:
a=3 b=4 c=$((7*a+b)) echo $c
or for interactive use, just
There are a number of command-line utilities for doing simple calculations:
to name just two of them. Be careful doing multiplication as if you don't escape your * the shell may try and interpret it as a wildcard.
Well your question is answered, but consider this:
Most of the linux distros have python preinstalled, so why not use it?
in the terminal and then do all the arithmetics you want, like
Will output 4 :)
Or Ruby. :)
Although it may not come pre-installed, it is pretty quick.