Convert units from one scale to another. The units are defined in an external data file. 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.

Syntax unitsoptions[FROM-UNIT[TO-UNIT]] Options -c --check Check that all units and prefixes defined in the units file reduce to primitive units. The program will print a list of all units that cannot be reduced. --check-verbose Like the '-check' option, this option prints a list of units that cannot be reduced. But to help find unit definitions that cause endless loops, it lists the units as they are checked. If 'units' hangs, then the last unit to be printed has a bad definition. -oformat--output-formatformatUse the specified format for numeric output. Format is the same as that for the printf function in the ANSI C standard. For example, if you want more precision you might use '-o %.15g'. -ffilename--filefilenameUsefilenameas the units data file rather than the default units data file 'units.dat'. -h --help Print out a summary of the options for 'units'. -q --quiet --silent Suppress prompting of the user for units and the display of statistics about the number of units loaded. -s --strict Suppress conversion of units to their reciprocal units. -v --verbose Give slightly more verbose output when converting units. When combined with the '-c' option this gives the same effect as '--check-verbose'. -V --version Print program version number, tell whether the readline library has been included, and give the location of the default units data file.

To invoke units for interactive use, type 'units' at your shell prompt.

The program will print something like this:

1161 units, 53 prefixes

You have:

At the 'You have:' prompt, type the quantity and units that you are converting
*from*. For example, if you want to convert ten meters to feet, type '10 meters'.
Next, 'units' will print 'You want:'. You should type the type of units you
want to convert *to*. To convert to feet, you would type 'feet'.

The answer will be displayed in two ways. The first line of output, which is
marked with a '*' to indicate multiplication, gives the result of the conversion
you have asked for. The second line of output, which is marked with a '/' to
indicate division, gives the inverse of the conversion factor. If you convert
10 meters to feet, 'units' will print:

* 32.808399

/ 0.03048

which tells you that 10 meters equals about 32.8 feet. The second number gives
the conversion in the reverse direction.

The 'units' program can perform units conversions non-interactively from the
command line. To do this, type the command, type the original units expression,
and type the new units you want. You will probably need to protect the units
expressions from interpretation by the shell using single quote characters.

If you type

units '2 liters' 'quarts'

then 'units' will print

* 2.1133764

/ 0.47317647

and then exit. The output tells you that 2 liters is about 2.1 quarts, or alternatively that a quart is about 0.47 times 2 liters.

In order to enter more complicated units or fractions, you will need to use operations such as powers, products and division. Powers of units can be specified using the '^' character as shown in the following example, or by simple concatenation: 'cm3' is equivalent to 'cm^3'. If the exponent is more than one digit, the '^' is required.

You have: cm^3 You want: gallons * 0.00026417205 / 3785.4118 You have: arabicfoot-arabictradepound-force You want: ft lbf * 0.7296 / 1.370614 Multiplication of units can be specified by using spaces, a hyphen ('-') or an asterisk ('*'). Division of units is indicated by the slash ('/'). You have: furlongs/fortnight You want: m/s * 0.00016630986 / 6012.8727Multiplication has a higher precedence than division and is evaluated left to right, so 'm/s * s/day' is equivalent to 'm / s s day' and has dimensions of length per time cubed. In effect, the first '/' character marks the beginning of the denominator of your unit. In particular, this means that writing '1/2 meter' refers to a unit of reciprocal length equivalent to .5/meter, which is probably not what you would intend if you entered that expression. To indicate division of numbers, use the vertical dash ('|'). No spaces area permitted on either side of the vertical dash character.

You have: 1|2 inch You want: cm * 1.27 / 0.78740157Prefixes are defined separately from base units. In order to get centimeters, the units database defines 'centi-' and 'c-' as prefixes.

Prefixes can appear alone with no unit following them. An exponent applies only to the immediately preceding unit and its prefix so that 'cm^3' or 'centimeter^3' refer to cubic centimeters but 'centi-meter^3' refers to hundredths of cubic meters. Only one prefix is permitted per unit, so 'micromicrofarad' will fail, but 'micro-microfarad' will work.

For 'units', numbers are just another kind of unit. They can appear as many times as you like and in any order in a unit expression. For example, to find the volume of a box which is 2 ft by 3 ft by 12 ft in steres, you could do the following:You have: 2 ft 3 ft 12 ft You want: stere * 2.038813 / 0.49048148 You have: $ 5 / yard You want: cents / inch * 13.888889 / 0.072And the second example shows how the dollar sign in the units conversion can precede the five. Be careful: 'units' will interpret '$5' with no space as equivalent to dollars^5.

Outside of the SI system, it is often desirable to add values of different units together. Sums of conformable units are written with the '+' character.You have: 2 hours + 23 minutes + 32 seconds You want: seconds * 8612 / 0.00011611705 You have: 12 ft + 3 in You want: cm * 373.38 / 0.0026782366 You have: 2 btu + 450 ft-lbf You want: btu * 2.5782804 / 0.38785542The expressions which are added together must reduce to identical expressions in primitive units, or an error message will be displayed:

You have: 12 printerspoint + 4 heredium Illegal sum of non-conformable units: 12 printerspoint reduces to 0.0042175176 m 4 heredium reduces to 20145.828 m^2Because '-' is used for products, it cannot also be used to form differences of units. If a '-' appears before numerical digits as the very first character on the input line or if it appears immediately after a '+' then the number will be evaluated as a negative number. So you can compute 20 degrees minus 12 minutes by entering '20 degrees+-12

arcmin'. The '+' character is sometimes used in exponents like '3.43e+8'. Exponents of this form cannot be used when forming sums of units, but they can be used otherwise.

The conversion information is read from a units data file which is called 'units.dat' and is probably located in the '/usr/local/share' directory. If you invoke 'units' with the '-V' option, it will print the location of this file. The default file includes definitions for all familiar units, abbreviations and metric prefixes. It also includes many obscure or archaic units.

Many constants of nature are defined, including these: pi ratio of circumference to diameter c speed of light e charge on an electron force acceleration of gravity mole Avogadro’s number water pressure per unit height of water Hg pressure per unit height of mercury au astronomical unit k Boltzman’s constant mu0 permeability of vacuum epsilon0 permitivity of vacuum G Gravitational constant mach speed of soundThe database includes atomic masses for all of the elements and numerous other constants. Also included are the densities of various ingredients used in baking so that '2 cups flour_sifted' can be converted to

'grams'. This is not an exhaustive list. Consult the units data file to see the complete list, or to see the definitions that are used.

The unit 'pound' is a unit of mass. To get force, multiply by the force conversion unit 'force' or use the shorthand 'lbf'. (Note that 'g' is already taken as the standard abbreviation for the gram.) The unit 'ounce' is also a unit of mass. The fluid ounce is 'fluidounce' or 'floz'. British capacity units that differ from their US counterparts, such as the British Imperial gallon, are prefixed with 'br'. Currency is prefixed with its country name: 'belgiumfranc', 'britainpound'.

The US Survey foot, yard, and mile can be obtained by using the 'US' prefix. These units differ slightly from the international length units. They were in use until 1959, but for geographic surveys, they are still used. The acre is officially defined in terms of the US Survey foot. If you want an acre defined according to the international foot, use 'intacre'. The difference between these units is about 4 parts per million. The British also used a slightly different length measure before 1959. These can be obtained with the prefix 'UK'.

When searching for a unit, if the specified string does not appear exactly as a unit name, then the 'units' program will try to remove a trailing 's' or a trailing 'es'. If that fails, 'units' will check for a prefix. All of the standard metric prefixes are defined.

To find out what units and prefixes are available, read the standard units data file.

All of the units and prefixes that 'units' can convert are defined in the units data file.

To add your own units data file - see the man pages for the file layout.

*“You have not converted a man because you have silenced him” ~ John Morley*

cal - Display a calendar.

dc - Desk Calculator.

factor - Print prime factors.

wc - Print byte, word, and line counts.

Copyright © 1999-2024 SS64.com

Some rights reserved

Some rights reserved