Is there a command line calculator for linux where I can do the following;
calc 560kB/12233kB
for example. Basic arithmetic desired and answers given as a decimal (in the case above) or with the appropriate SI prefix (kB, B, MB, GB, etc.).
Could bc
do the trick somehow?
GNU Units does what I wanted to.
You can abuse bc
for this if you remember that number unit
actually is a shorthand for number * unit
. One limitation of bc
is that it only allows lower-case variables:
b=1
kb=1024
mb=1024*kb
...
scale=20
(560*kb)/(12233*kb)
.04577781410937627728
The next thing that I could think of is Python together with the units package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With