Best part of reading this is coming away having learned the existence of units the CLI. How did I spend 20 years on the shell and not have needed or discovered this?
One thing I got bitten by was the handling of Fahrenheit/Celsius, because it's a non-linear conversion between the two. When you ask to convert `10 degC` to `degF` you get 18, which is the delta of ºF corresponding to increment of 10ºC. To get the absolute temperature, you have to ask to convert `tempC(10)` to `tempF` which is 50, as expected.
"Non-linear" threw me off for a second - I almost never see the mathematically correct definition of linear in computer science spaces. For anyone wondering, Celsius to Fahrenheit is an affine transform, technically not linear, because you have to add an offset, not just multiply.
$ units
Currency exchange rates from FloatRates (USD base) on 2020-05-12
$ sudo units_cur
$ units
Currency exchange rates from FloatRates (USD base) on 2020-07-09
Looking at the source of the default configuration (cat /usr/share/misc/units.lib), I believe it only defines conversions for currencies that are pegged to another one (mainly to EUR or USD).
You have: 10 franc
You want: dollar
conformability error
1.5244902 euro
1 usdollar
You have: 10 franc
You want: euro
* 1.5244902
/ 0.655957
'units' was new to me too. The version I have on my Mac wouldn't accept 'millilightseconds' but it would take 'milli-c-seconds' - presumably the units.lib database is a little different from one in the original article.
cranium|5 years ago
https://www.gnu.org/software/units/
comicjk|5 years ago
m000|5 years ago
It seems that GNU units at some point added support for several non-linear units, which may have prompted them to rethink their syntax.
ornornor|5 years ago
duckerude|5 years ago
throwaway744678|5 years ago
zerocrates|5 years ago
gerdesj|5 years ago
divbzero|5 years ago
lozf|5 years ago
pedrow|5 years ago
petercooper|5 years ago
punnerud|5 years ago
You have: mph
You want: kph
majewsky|5 years ago
nrzd|5 years ago