3 ms·
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 somet
by zokier 6y ago
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/numfmt-invocation.html https://www.gnu.org/software/coreutils/manual/html_node/numf...
- paedubucher 6y agoIt'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.
- michaelcampbell 6y ago> 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.
- renox 6y agoNice but somehow I feel that PowerShell users aren't impressed..