Command line calculator
There is bc utility which takes expression similar to C programming language.
Add this function to your ~/.bashrc or ~/.bash_profile:
calc () { echo "$*" | bc -l; }
Then you can use like:
$ calc 2^20 - 256
If you use parenthesis, enclose expression by double quotes:
$ calc "7*(7-6)*6"
Or you can you use bc directly:
$ bc -l <<< "7*7-6*6"
Written by Ochko
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Related Tags
#shell
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#