Is there a standard command that will format a simple value (size in bytes) as a human readable format (similar to the -h switch on du, ls, ...)?


echo 1852 | format       # should print 1.9K
echo 3145728000 | format # should print 3.0G

1 Answer 1


I think you are looking for the numfmt tool, which can covert raw strings to known math standards, e.g.

 echo 3145728000 | numfmt --to=iec

The tool is part of the GNU coreutils family.

  • 1
    numfmt isn’t a standard command. Sep 15, 2020 at 8:38
  • Agreed, will wait for a confirmation to see if OP doesn't have GNU coreutils
    – Inian
    Sep 15, 2020 at 8:40
  • Perfect, thanks! I was able to find numfmt on Arch/Ubuntu.
    – laktak
    Sep 15, 2020 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.