Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Okay, thanks. About your script, I basically really like it. There are a few things which caught my attention: (1) var s should be have leading B. Also this string is easily changed to IEC Binary notation. (2) It skips the 1000-1023 range in favour of 1<next size> (easily changed) (3) It does not have decimal values (which I do want). Again this is easily changed. When displaying 2 decimal places, the %f format causes a round-up to the <next size> for values 1019-1023; but it's not worth a workaround ..I've posted a modified version in my answer, for general reference. Commented Jul 27, 2012 at 8:17
  • 2
    gnumfmt for osx homebrew users using coreutils Commented Mar 9, 2016 at 22:11
  • For those who want to convert du numbers to human-readable format, note that you might need to add --block-size=1 to du command. Commented Oct 25, 2018 at 19:51
  • You actually can pass --format %.2f to get 2 digits after decimal point. Commented Aug 25, 2022 at 0:24
  • @bentocin Thanks! That was actually added shortly after I wrote this answer. Commented Aug 25, 2022 at 10:34