numfmt --to=iec --suffix=B 1048576

Category: Data Science & Analysis

numfmt --to=iec --suffix=B 1048576

Format a byte count in IEC units with a B suffix

The iec target uses binary units (powers of 1024), so 1048576 becomes 1.0M, and --suffix=B appends the letter B to yield 1.0MB. This is the exact formatting used by ls -lh for file sizes. The raw number can come from a pipe instead of the argument. Use --from=iec to parse such strings back into plain numbers.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.