Linux command
units 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Start interactive mode
units
Convert between units
units "[from_unit]" "[to_unit]"
Convert specific quantity
units "[100 kilometers]" "[miles]"
Show definition
units "[parsec]"
Use terse output
units --terse "[from_unit]" "[to_unit]"
Check units database
units --check
Use a custom units file
units -f [custom_units.dat]
Display version and data file location
units -V
说明
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.
参数
- -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.
FAQ
What is the units command used for?
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.
How do I run a basic units example?
Run `units` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f _filename_, --file _filename_ do in units?
Use specified units database file.