Go to the first, previous, next, last section, table of contents.


Using units non-interactively

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.

If the conversion is successful, then units will return success to the calling environment. If units is given non-conformable units to convert, it will print a message giving the reduced form of each unit and it will return failure to the calling environment.

When units is invoked with only one argument, it will print out the definition of the specified unit. It will return failure if the unit is not defined and success if the unit is defined.


Go to the first, previous, next, last section, table of contents.