Scroll to navigation

numfmt(1) General Commands Manual numfmt(1)

NAME

numfmt - Convert numbers from/to human-readable strings

SYNOPSIS

numfmt [--debug] [-d|--delimiter] [--field] [--format] [--from] [--from-unit] [--to] [--to-unit] [--padding] [--header] [--round] [--suffix] [--unit-separator] [--invalid] [-z|--zero-terminated] [-h|--help] [-V|--version] [NUMBER]

DESCRIPTION

Convert numbers from/to human-readable strings

OPTIONS

numfmt-help-debug
use X instead of whitespace for field delimiter
replace the numbers in these input fields; see FIELDS below
use printf style floating-point FORMAT; see FORMAT below for details
auto-scale input numbers to UNITs; see UNIT below
specify the input unit size
auto-scale output numbers to UNITs; see UNIT below
the output unit size
pad the output to N characters; positive N will right-align; negative N will left-align; padding is ignored if the output is wider than N; the default is to automatically pad if a whitespace is found
print (without converting) the first N header lines; N defaults to 1 if not specified
use METHOD for rounding when scaling

[possible values: up, down, from-zero, towards-zero, nearest]

print SUFFIX after each formatted number, and accept inputs optionally ending with SUFFIX
numfmt-help-unit-separator
set the failure mode for invalid input

[possible values: abort, fail, warn, ignore]

line delimiter is NUL, not newline
Print help
Print version

EXTRA

UNIT options:

- none: no auto-scaling is done; suffixes will trigger an error - auto: accept optional single/two letter suffix:


1K = 1000, 1Ki = 1024, 1M = 1000000, 1Mi = 1048576,

- si: accept optional single letter suffix:


1K = 1000, 1M = 1000000, ...

- iec: accept optional single letter suffix:


1K = 1024, 1M = 1048576, ...

- iec-i: accept optional two-letter suffix:


1Ki = 1024, 1Mi = 1048576, ...

- FIELDS supports cut(1) style field ranges:


N N'th field, counted from 1
N- from N'th field, to end of line
N-M from N'th to M'th field (inclusive)
-M from first to M'th field (inclusive)
- all fields

Multiple fields/ranges can be separated with commas

FORMAT must be suitable for printing one floating-point argument %f. Optional quote (%'f) will enable --grouping (if supported by current locale). Optional width value (%10f) will pad output. Optional zero (%010f) width will zero pad the number. Optional negative values (%-10f) will left align. Optional precision (%.1f) will override the input determined precision.

VERSION

v(uutils coreutils) 0.7.0

EXAMPLES

Convert 1.5K (SI Units) to 1500:

numfmt --from si 1.5K

Convert 1500 to 1.5K (SI Units):

numfmt --to si 1500

Convert 1.5K (IEC Units) to 1536:

numfmt --from iec 1.5K

Use appropriate conversion based on the suffix:

numfmt --from auto 1.5Ki

Convert 5th field (1-indexed) to IEC Units without converting header:

ls -l | numfmt --header=1 --field 5 --to iec

Convert to IEC units, pad with 5 characters, left aligned:

du [-s|--summarize] * | numfmt --to iec --format "%-5f"

The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.

numfmt (uutils coreutils) 0.7.0