Sunday, April 10, 2011

Is There any Calculator in Terminal?

Yeah, absolutely. You can use bc package in Linux Ubuntu. This is an arbitrary precision calculator language. Or, we can just call it "bash calculator" (bc). Simply issue this command:
apt-get install bc
Of course you have to be a root when issuing it. Now we will try bc to perform simple arithmetic operation, such as:
echo 2+3 | bc
echo 2-3 | bc
echo 2*3 | bc
echo 6/2 | bc

Run them in terminal and you will get output: 5, -1, 6, and 2. We will use this calculator later in the next tutorial. Enjoy!

No comments: