Units (command)

From Christoph's Personal Wiki
Revision as of 22:12, 16 April 2007 by Christoph (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
The correct title of this article is units. The initial letter is capitalized due to technical restrictions.

units is a command line unit conversion program.

The units program converts quantities expressed in various scales to their equivalents in other scales. The units program can handle multiplicative scale changes as well as nonlinear conversions such as Fahrenheit to Celsius.

The units are defined in an external data file (usually found in /usr/share/units.dat on SuSE), in plain text format, and it is in fact a good source of information in itself. You can use the extensive data file that comes with this program, or you can provide your own data file to suit your needs.

You can use the program interactively with prompts, or you can use it from the command line.

It has a huge database of units, including esoteric and historical units. This for instance allows you to convert velocities specified in furlongs per fortnight, if you really wish.

units has been a standard part of Unix since the early Bell Laboratories versions.

The GNU free software version is written by Adrian Mariano

Usage

units [option] ['from-unit' 'to-unit']
   -h, --help          print this help and exit
   -c, --check         check that all units reduce to primitive units
       --check-verbose like --check, but lists units as they are checked
                         so you can find units that cause endless loops
   -e, --exponential   exponential format output
   -f, --file          specify units data files (-f  loads default file)
   -m, --minus         make - into a subtraction operator (default)
   -o, --output-format specify printf numeric output format
   -p, --product       make - into a product operator
   -q, --quiet         supress prompting
       --silent        same as --quiet
   -s, --strict        suppress reciprocal unit conversion (e.g. Hz<->s)
   -t, --terse         print terse conversion factor output
   -v, --verbose       print slightly more verbose output
   -V, --version       print version number and exit

Examples

Note: Taken from GNU Units homepage.

  • Two simple conversion examples:
   You have: mile
   You want: km
           * 1.609344
           / 0.62137119
   You have: furlongs per fortnight
   You want: m/s  
           * 0.00016630986
           / 6012.8727
  • A calculation involving roots of units:
   You have: (400 W/m^2 / stefanboltzmann)^(1/4)
   You have:
           Definition: 289.80882 K
  • Temperature differences are converted using the syntax shown above with unit names like degC and degF. But conversion of absolute temperatures requires a different syntax:
   You have: tempF(45)
   You want: tempC
           7.2222222

Sources

  • Most units data was drawn from:
    1. "NIST Special Publication 811" (1995 Edition)
    2. "CRC Handbook of Chemistry and Physics" (70th Edition)
    3. "Oxford English Dictionary"
    4. "Websters New Universal Unabridged Dictionary"
    5. "Units of Measure" by Stephen Dresner
    6. "A Dictionary of English Weights and Measures" by Ronald Zupko
    7. "British Weights and Measures" by Ronald Zupko
    8. "Realm of Measure" by Isaac Asimov
    9. "United States standards of weights and measures, their creation and creators" by Arthur H. Frazier.
    10. "French weights and measures before the Revolution: a dictionary of provincial and local units" by Ronald Zupko
    11. "Weights and Measures: their ancient origins and their development in Great Britain up to AD 1855" by FG Skinner
    12. "The World of Measurements" by H. Arthur Klein
    13. "For Good Measure" by William Johnstone
    14. "NTC's Encyclopedia of International Weights and Measures" by William Johnstone
    15. "Sizes" by John Lord
    16. "Sizesaurus" by Stephen Strauss
    17. "CODATA Recommended Values of Physical Constants"
    18. "How Many? A Dictionary of Units of Measurement"
    19. "Numericana"
    20. "UK history of measurement"

External links