Discovering a new UNIX tool - units
When reading that article - which by the way is worth having a look at! - I discovered a new UNIX tool which I wasn't aware of: units
units
is a conversion calculator - from its man page (UNITS(1)):
The units program converts quantities expressed in various scales to
their equivalents in other scales.
Fun! I wasn't aware of this nice tool.
Trying units
It is available on a default FreeBSD install, let's give it a try!
% units
586 units, 56 prefixes
You have:
Right, so you need to answer to "You have"
with the initial quantity and unit,
and then specify to which unit you want to convert to.
Let's try converting 3 kilometers to miles:
You have: 3 kms
You want: miles
* 1.8641136
/ 0.536448
=> 3 kilometers makes ~1.86 miles.
The last line gives you the calculation that
units
used.
Now let's convert an hour to seconds:
You have: 1 hour
You want: seconds
* 3600
/ 0.00027777778
And finally 2 days to minutes:
You have: 2 days
You want: minutes
* 2880
/ 0.00034722222
Trying weird conversion
Sure you can try converting to something completely crazy, but units
will
complain - e.g. convertings 3 milliseconds to miles!
You have: 3 milliseconds
You want: miles
conformability error
0.003 sec
1609.344 m