APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed


This is a converter. It gives you conversion factors for feet to inches, miles to meters, that sort of thing. It can be used directly at the command line or interactively. You can modify the data file it uses or create your own for special purposes.

bash-2.05a$ units ton grain
        * 14000000
        / 7.1428571e-08

Which tells you that you'd need to multiply by 14000000 to convert tons to grains. Interactively:

bash-2.05a$ units
501 units, 41 prefixes

You have: 4 meters
You want: inches
        * 157.48031
        / 0.00635
You have: 

The /usr/share/misc/units.lib (could be different on your system) is the file that tells units how to do its conversions; you can add to that or provide your own file:

bash-2.05a$ cat med
aspirin                 !a!
headache                        2 aspirin
bash-2.05a$ units -f med headache aspirin
        * 2
        / 0.5

Units can only do simple math; it can't convert Fahrenheit to Centrigrade. It can do currency conversions, but you'd need to keep its file up to date.

Of course today we have Google, which can answer many such problems itself or find you a calculator to do it.

Got something to add? Send me email.

Increase ad revenue 50-250% with Ezoic

More Articles by

Find me on Google+

© Tony Lawrence

Kerio Samepage

Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

If we define Futurism as an exploration beyond accepted limits, then the nature of limiting systems becomes the first object of exploration. (Frank Herbert)

This post tagged: