units
utilitiesLinux/Unix
The units command is one of the most frequently used commands in Linux/Unix-like operating systems. units Convert quantities between different units
Quick Reference
Command Name:
units
Category:
utilities
Platform:
Linux/Unix
Basic Usage:
units [options] [arguments]
Common Use Cases
Syntax
units [options] [from-unit [to-unit]]
Options
| Option | Description |
|---|---|
-c, --check |
Check that all units and prefixes are defined |
-o, --output-format FORMAT |
Specify the output format: one of 'default', 'compact', or 'raw' |
-f, --file FILE |
Specify units data file |
-p, --product PRODUCT |
Print product of converted unit and NUMBER |
-r, --round ROUND |
Round output to ROUND digits (default is 12) |
-s, --strict |
Apply strict conversion rules |
-t, --terse |
Display terse output (conversion factor only) |
-v, --verbose |
Display verbose output (unit definitions) |
-1, --one-line |
Display output on one line |
-q, --quiet |
Suppress prompting |
-h, --help |
Display help and exit |
-V, --version |
Print version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the units command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
Interactive mode
units
Convert 5 kilometers to miles
units "5 kilometers" miles
Convert 100 degrees Celsius to Fahrenheit
units "100 celsius" fahrenheit
Convert 1 hour to seconds
units "1 hour" seconds
Advanced Examples:
Convert currency (assuming updated currency database)
units "100 USD" EUR
Convert data storage units
units "1 gigabyte" "megabits"