Linux Tips and Tricks

Linux Tips and Tricks

Terminal Calculator

November3

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
10

$calc 10*5
50
 

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

$ calc "s(45)"
.85090352453411842486

$ calc "c(90)"
-.44807361612917015236
 

posted under Uncategorized

Email will not be published

Website example

Your Comment:


Recent Comments

    Categories