I use GNU Units to convert measurements.
The program knows about many obscure and antiquated units, but I mostly use it for boring things like converting currencies and between metric and imperial units. It can be used directly from the command line, or via a prompted interactive mode.
$ units 57EUR USD
Currency exchange rates from FloatRates (USD base) on 2019-07-24
3460 units, 109 prefixes, 109 nonlinear units
You have: 16 floz
You want: ml
You have: tempC(30)
You want: tempF
GNU Units is picky about its unit definitions, and they are case sensitive. For example, it knows what
USD is, but
usd is undefined. It supports tab completion of units in interactive mode, which can be helpful. It knows the difference between a US fluid ounce and a British fluid ounce.
$ units "1 usfloz" ml
$ units "1 brfloz" ml
The unit definitions are stored at
/usr/share/units/definitions.units. Occasionally I’ll need to peruse through this file to find the correct formatting for the unit I’m interested in. Sometimes when doing this I’ll run into one of the more obscure definitions, such as
beespace. Apparently this unit is used in beekeeping when designing hive boxes. It is described in the definition file thusly: “Bees will fill any space that is smaller than the bee space and leave open spaces that are larger. The size of the space varies with species.”
$ units 12inches beespace
Every so often you need to know how many Earth days are in one Martian year. With GNU Units that information is a few keystrokes away.
$ units 1marsyear days
Currency definitions are stored in
/var/lib/units/currency.units. They are updated using the
units_cur program. In the past I would update currencies whenever I needed them, but recently I setup a systemd timer to update these definitions roughly once per day (depending on network connectivity). This provides me with conversion rates that are current enough for my own use, which I can take advantage of even when offline, and does not require me to let a third party know which currencies or quantities I am interested in.
Astute readers will have noted that I am big on this offline computing thing.