from small one page howto to huge articles all in one place
Last additions:
May 25th. 2007:
April, 26th. 2006:
|
You are here: manpages
NUMFMT
Section: User Commands (1) Updated: February 2026 Index
Return to Main Contents
NAME
numfmt - Convert numbers from/to huma-readable strings
SYNOPSIS
numfmt
[ ,OPTION/]... [ ,NUMBER/]...
DESCRIPTION
Reformat NUMBER(s), or the numbers from standard input if none are specified.
Mandatory arguments to long options are mandatory for short options too.
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-debug'--debugX'tty: link'
-
print warnings about invalid input
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-d'-d, --delimiter=,XX'tty: link'/
-
use X instead of whitespace for field delimiter
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-field'--field=FIELDSX'tty: link'
-
replace the numbers in these input fields (default=1);
see FIELDS below for details
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-format'--format=FORMATX'tty: link'
-
use printf style floating-point FORMAT;
see FORMAT below for details
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-from'--from=UNITX'tty: link'
-
auto-scale input numbers to UNITs; default is 'none';
see UNIT below for details
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-fro-unit'--from-unit=NX'tty: link'
-
specify the input unit size (instead of the default 1)
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-grouping'--groupingX'tty: link'
-
use locale-defined grouping of digits, e.g. 1,000,000.
This has no effect in the C/POSIX locale
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-header'--header[=N]X'tty: link'
-
print (without converting) the first N header lines;
N defaults to 1 if not specified
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-invalid'--invalid=MODEX'tty: link'
-
failure mode for invalid numbers;
MODE can be: abort (default), fail, warn, ignore
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-padding'--padding=NX'tty: link'
-
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
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-round'--round=METHODX'tty: link'
-
use METHOD for rounding when scaling; METHOD can be:
up, down, from-zero (default), towards-zero, nearest
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-suffix'--suffix=SUFFIXX'tty: link'
-
add SUFFIX to output numbers,
and accept an optional SUFFIX in input numbers
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-uni-separator'--unit-separator=SEPX'tty: link'
-
insert SEP between number and unit on output,
and accept an optional SEP in input numbers
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-to'--to=UNITX'tty: link'
-
auto-scale output numbers to UNITs; see UNIT below
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-t-unit'--to-unit=NX'tty: link'
-
the output unit size (instead of the default 1)
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#numfm-z'-z, --zero-terminatedX'tty: link'
-
line delimiter is NUL, not newline
- X'tty: link https://www.gnu.org/software/coreutils/numfmt#numfm-help'--helpX'tty: link'
-
display this help and exit
- X'tty: link https://www.gnu.org/software/coreutils/numfmt#numfm-version'--versionX'tty: link'
-
output version information and exit
UNIT options:
- none
-
no auto-scaling is done; suffixes will trigger an error
- auto
-
accept optional single/two letter suffix:
1K = 1000, 1k = 1000,
1Ki = 1024,
1M = 1000000,
1Mi = 1048576,
- si
-
accept optional single letter suffix:
1k = 1000, 1K = 1000,
1M = 1000000,
...
- iec
-
accept optional single letter suffix:
1K = 1024, 1k = 1024,
1M = 1048576,
...
- iec-i
-
accept optional two-letter suffix:
1Ki = 1024, 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.
Exit status is 0 if all input numbers were successfully converted.
By default, numfmt will stop at the first conversion error with exit status 2.
With --invalid=,'fail'/ a warning is printed for each conversion error
and the exit status is 2. With --invalid=,'warn'/ each conversion error is
diagnosed, but the exit status is 0. With --invalid=,'ignore'/ conversion
errors are not diagnosed and the exit status is 0.
EXAMPLES
-
mono]$ numfmt-to=si 1000/mono]
-
-> "1.0k"
-
mono]$ numfmt-to=iec 2048/mono]
-
-> "2.0K"
-
mono]$ numfmt-to=ie-i 4096/mono]
-
-> "4.0Ki"
-
mono]$ echo 1K | numfmt-from=si/mono]
-
-> "1000"
-
mono]$ echo 1K | numfmt-from=iec/mono]
-
-> "1024"
-
mono]$ df-B1 | numfmt-header-field -4-to=si/mono]
mono]$ ls-l | numfmt-header-field 5-to=iec/mono]
mono]$ ls-lh | numfmt-header-field 5-from=iec-padding=10/mono]
mono]$ ls-lh | numfmt-header-field 5-from=iec-format %10f/mono]
AUTHOR
Written by Assaf Gordon.
REPORTING BUGS
Report bugs to: bug-coreutils@gnu.org
Report Gentoo bugs to: https://bugs.gentoo.org/
GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>
Report any translation bugs to <https://translationproject.org/team/>
SEE ALSO
Full documentation < https://www.gnu.org/software/coreutils/numfmt>
or available locally via: info aq(coreutils) numfmt invocationaq
Packaged by Gentoo (9.10 (p0))
Copyright © 2026 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- UNIT options:
-
- FIELDS supports cut(1) style field ranges:
-
- EXAMPLES
-
- AUTHOR
-
- REPORTING BUGS
-
- SEE ALSO
-
|