Last Updated: February 25, 2016
·
945
· milani

scientific calculator for terminal

Isn't it too much to find calculator app and open it in order to do math? Linux users have always a command line open, so they can use it as a calculator. For me, I often need something more than a simple calculator. So here it is what I did!

I opened my ~/.bashrc and implemented my own calculator function using R.

function = {
    R -q --vanilla -e "$@" | grep -E '[^>](.*)' -o -x --color=never
}

Now, all I need to do is:

$ = 'sqrt(2^2)*0.3888'
$ = 'sample <- rnorm(100); mean(sample)'
  • Note: you will need R installed. On ubuntu simply do sudo apt-get install r-base-core