Linux Tips and Tricks

Linux Tips and Tricks

Terminal Calculator


In this example, i am gonna to show how to create a Terminal Calculator.

Open your .bashrc file from your home directory (It is a hidden file). Before making changes, please take a backup of the .bashrc file.

Open the file and add the below lines in your end of the .bashrc file.

#calculator function

function calc
  echo "${1}" | bc -l;

And save the .bashrc file.

Now, just restart your console. and type the below command.

$ calc 5+5

$calc 10*5

If you like to calculate the sine and cosine values, then you have to use it like this

$ calc "s(45)"

$ calc "c(90)"

posted under Uncategorized

Email will not be published

Website example

Your Comment:

Recent Comments