NUMFMT(1)

πŸ’– NUMFMT πŸ’–

okay bestie, sit down, because numfmt (that's section 1 of the General Commands Manual, if you were wondering) is literally the glow-up your numbers have been begging for 🫢

✨ NAME ✨

numfmt β€” convert numbers from/to human-readable strings. yes. that's the whole vibe. numbers that look like 1048576 get to wear a cute little 1Mi outfit and honestly? iconic.

🌸 SYNOPSIS 🌸

numfmt [OPTION]... [NUMBER]...

πŸ¦‹ DESCRIPTION πŸ¦‹

Convert numbers from/to human-readable strings. she does one thing and she eats every single time πŸ’…

πŸ‘‘ OPTIONS πŸ‘‘

  • --debug β€” print warnings about invalid input. like, she'll tell you when something's giving sus data πŸ‘€
  • --grouping β€” use locale-defined grouping of digits, for example 1,000,000. heads up though: this means it has no effect in the C/POSIX locale, so if nothing happens, that's why, not you πŸ₯²
  • -d, --delimiter <X> β€” use X instead of whitespace for the field delimiter
  • --field <FIELDS> [default: 1] β€” replace the numbers in these input fields; peep FIELDS below for the tea
  • --format <FORMAT> β€” use printf style floating-point FORMAT; details are down in FORMAT, don't skip it bestie
  • --from <UNIT> [default: none] β€” auto-scale input numbers to UNITs; see UNIT below
  • --from-unit <N> [default: 1] β€” specify the input unit size
  • --to <UNIT> [default: none] β€” auto-scale output numbers to UNITs; see UNIT below
  • --to-unit <N> [default: 1] β€” the output unit size
  • --padding <N> β€” 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
  • --header[=<N>] β€” print (without converting) the first N header lines; N defaults to 1 if not specified
  • --round <METHOD> [default: from-zero] β€” use METHOD for rounding when scaling. possible values are:
    • up
    • down
    • from-zero
    • towards-zero
    • nearest
  • --suffix <SUFFIX> β€” print SUFFIX after each formatted number, and accept inputs optionally ending with SUFFIX
  • --unit-separator <STRING> β€” use STRING to separate the number from any unit when printing; by default, no separator is used
  • --invalid <INVALID> [default: abort] β€” set the failure mode for invalid input. possible values are:
    • abort
    • fail
    • warn
    • ignore
  • -z, --zero-terminated β€” line delimiter is NUL, not newline
  • -h, --help β€” Print help
  • -V, --version β€” Print version

πŸ’œ EXTRA πŸ’œ

the UNIT options, explained

  • 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 (cut-core energy, fr fr)

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

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.12.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. (not her fault, she's growing 🌱)


okay that's the whole page, and before you go: this little masterpiece is dated 2026-09-25, so that's the era of numfmt you're living in. go forth and make your numbers pretty, bestie πŸ’–βœ¨πŸŒΈ no cap.

πŸ“¦ where this page comes from