LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

units

Convert between measurement units

TLDR

Start interactive mode for unit conversions
$ units
copy
Convert between units directly
$ units "[from_unit]" "[to_unit]"
copy
Convert specific quantity
$ units "[100 kilometers]" "[miles]"
copy
Show definition of a unit
$ units "[parsec]"
copy
Use terse output (for scripts)
$ units --terse "[from_unit]" "[to_unit]"
copy
Check units database for errors
$ units --check
copy
Use a custom units file
$ units -f [custom_units.dat]
copy
Display version and data file location
$ units -V
copy

SYNOPSIS

units [options] [from-unit] [to-unit]

DESCRIPTION

GNU Units converts between different systems of measurement and performs unit arithmetic. It includes a comprehensive database of over 3000 units, including historical and esoteric measurements.In interactive mode, enter the source unit at the "You have:" prompt and the target unit at "You want:". Units checks dimensional compatibility and reports conformability errors for incompatible conversions.The program also functions as a scientific calculator with built-in functions (sin, cos, ln, exp, etc.). Complex expressions with units are supported.

PARAMETERS

-f filename, --file filename

Use specified units database file.
-c, --check
Check that all units reduce to primitive units.
-o format, --output-format format
Specify numeric output format (printf-style).
-d ndigits, --digits ndigits
Set number of significant digits in output.
-e, --exponential
Use scientific (exponential) notation for output.
-t, --terse
Print only the conversion factor (for parsing).
--compact
Give compact output without operators.
-q, --quiet
Suppress statistics and prompts.
-v, --verbose
Show more detailed output.
--list-units
List all known units and exit.
--conformable
Show units conformable with the given expression.
-u system, --units system
Use alternative unit system (e.g., si, cgs, natural).
--locale locale
Force a specific locale.
--minus
Interpret - as subtraction (default).
--product
Interpret - as multiplication.
-V, --version
Print version and data file location.
-h, --help
Display help message.

CAVEATS

Attempting to convert between dimensionally incompatible units (e.g., meters to seconds) produces a conformability error. The units database location varies by installation; use -V to find it. Custom unit definitions can be added to personal unit files.

HISTORY

The original Unix units program was included in early versions of Unix. GNU Units was written by Adrian Mariano as a free implementation with an expanded unit database. It was first released in 1996 and is maintained as part of the GNU Project. The program includes units from ancient civilizations, historical measurements, and modern scientific standards.

SEE ALSO

bc(1), dc(1), calc(1)

Copied to clipboard
Kai