numfmt
TLDR
Convert bytes to human-readable
SYNOPSIS
numfmt [--from=UNIT] [--to=UNIT] [--field=N] [options] [numbers]
DESCRIPTION
numfmt converts numbers to and from human-readable representations. It handles both SI units (powers of 1000: K, M, G) and IEC units (powers of 1024: Ki, Mi, Gi).
Input parsing (--from) interprets suffixed numbers: 10K becomes 10000 (SI) or 10240 (IEC). Output conversion (--to) formats numbers with appropriate suffixes for readability.
For processing command output, --field selects which column to convert, and --header preserves header rows. This enables piping output from commands like df or ls through numfmt for human-readable conversion.
The --format option provides printf-style control: `%10.2f` for fixed-width decimal output. Combined with --grouping, numbers display with locale-appropriate thousands separators.
Rounding modes control how fractional values are handled. The default rounds to nearest, but ceiling (up) or floor (down) may be preferred for storage calculations.
PARAMETERS
--from= UNIT
Parse input units (auto, si, iec, iec-i).--to= UNIT
Convert to units (si, iec, iec-i).--field= N
Convert field N (default: 1).--header[=N]
Skip N header lines (default: 1).--padding= N
Pad output to N characters.--suffix= STR
Append suffix to output.--format= FMT
Printf-style format.--round= METHOD
Rounding: up, down, from-zero, towards-zero, nearest.--grouping
Use locale digit grouping (e.g., 1,000).--delimiter= D
Use D as field delimiter.--invalid= MODE
Handle invalid input: abort, fail, warn, ignore.-d D
Short for --delimiter.--debug
Print conversion warnings.
CAVEATS
SI and IEC units differ significantly at large values. The 'iec-i' format uses explicit "Ki" suffix while 'iec' uses just "K". Floating-point precision may affect very large numbers. Not all locales support grouping.
HISTORY
numfmt is part of GNU coreutils, added to provide standardized number formatting across utilities. It addresses the inconsistency of human-readable output between different commands, providing a single tool for number conversion that respects both SI and IEC standards.


