News for hackers. Stuff that matters.
Re:Sort of handy by zokier on Thursday May 21, 2020 @04:16AM (#23255996)
Pretty great example on how the unix pipeline of strings falls apart because the data is so constrained by formatting.

Slightly cleaner solution would be something like

    du | sort | numfmt
(with appropriate flags)

https://www.gnu.org/software/coreutils/manual/html_node/numf...

Re:Sort of handy by paedubucher on Thursday May 21, 2020 @05:43AM (#23256505)
It's not the pipeline that falls apart, it's the formatting of data that is applied too early in the process. Report the sizes numerically in the same unit, sort them numerically, and then format the numbers in a human readable fashion.

`sort -h` is only needed because `du -h` is used in the first place. I admit that `du -h` comes in handy often, it is better not used for further processing.

Your proposed approach is not only more Unix-like, but also does not require bloated implementations of `du` and `sort` capable of parsing human-readable size indications.

Re:Sort of handy by michaelcampbell on Thursday May 21, 2020 @06:05AM (#23256635)
> I admit that `du -h` comes in handy often, it is better not used for further processing.

I'd posit that once you use -h or equivalent, any further processing by a NON-HUMAN that works the way you want is a lucky side effect.

Re:Sort of handy by renox on Friday May 22, 2020 @04:28PM (#23276569)
Nice but somehow I feel that PowerShell users aren't impressed..