Next: Unit Definitions, Previous: Interacting with units
, Up: Units Conversion [Contents][Index]
units
Non-InteractivelyThe units
program can perform units conversions non-interactively
from the command line. To do this, type the command, type the original
unit expression, and type the new units you want. If a units expression
contains non-alphanumeric characters, you may need to protect it from
interpretation by the shell using single or double 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.
units
does not require a space between a numerical value and
the unit, so the previous example can be given as
units 2liters quarts
to avoid having to quote the first argument.
If the conversion is successful, units
will return success (zero)
to the calling environment. If you enter non-conformable units, then
units
will print a message giving the reduced form of each
unit and it will return failure (nonzero) to the calling environment.
If the --conformable option is given, only one unit expression
is allowed, and units
will print all units conformable with
that expression; it is equivalent to giving ? at the
‘You want:’ prompt. For example,
units --conformable gauss B_FIELD tesla Gs gauss T tesla gauss abvolt sec / cm^2 stT stattesla statT stattesla stattesla statWb/cm^2 tesla Wb/m^2
If you give more than one unit expression with the --conformable option, the program will exit with an error message and return failure. This option has no effect in interactive mode.
If the --terse (-t) option is given with the --conformable option, conformable units are shown without definitions; with the previous example, this would give
units --terse --conformable gauss B_FIELD Gs T gauss stT statT stattesla tesla
When the --conformable option is not given and you invoke
units
with only one argument, units
will print the
definition of the specified unit. It will return failure if the unit is
not defined and success if the unit is defined.
Next: Unit Definitions, Previous: Interacting with units
, Up: Units Conversion [Contents][Index]