bc is a great command line calculator for Linux. Under Debian based distributions just:
apt-get install bc
Here are some simple usage examples:
ns3:~# bc
bc 1.06.94
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty’.
2+2
4
5+5*5
30
(5+5)*5
50
2^8
256
We can also pipe input to bc via stdin:
ns3:~# echo ‘7+7′|bc
14
ns3:~# echo ‘2895643%1966′|bc
1691
ns3:~# echo ‘3^6′|bc
729
ns3:~#
It’s that easy!
Tags: apt-get, bc, debian, Linux, stdin
Leave a Comment