2025-03-14 21:59:59 -06:00
|
|
|
# numfmt
|
|
|
|
|
|
|
|
|
|
> Convert numbers to and from human-readable strings.
|
|
|
|
|
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/numfmt-invocation.html>.
|
|
|
|
|
|
|
|
|
|
- Convert 1.5K (SI Units) to 1500:
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`numfmt --from si 1.5K`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2026-02-18 06:55:01 -07:00
|
|
|
- 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}}`
|
|
|
|
|
|
2025-03-14 21:59:59 -06:00
|
|
|
- Convert 5th field (1-indexed) to IEC Units without converting header:
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`ls -l | numfmt --header=1 --field 5 --to iec`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Convert to IEC units, pad with 5 characters, left aligned:
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`du {{[-s|--summarize]}} * | numfmt --to iec --format "%-5f"`
|