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.
Slightly cleaner solution would be something like
(with appropriate flags)https://www.gnu.org/software/coreutils/manual/html_node/numf...