GNU bug report logs -
#20936
sort: add summary line option
Previous Next
Reported by: Linda Walsh <coreutils <at> tlinx.org>
Date: Tue, 30 Jun 2015 07:29:02 UTC
Severity: wishlist
Tags: wontfix
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 20936 <at> debbugs.gnu.org (full text, mbox):
Hello,
On 06/30/2015 03:28 AM, Linda Walsh wrote:
> I admit the ability to show a summary line might not bethe first
> thing you'd think a pure-sorting utility might do, but it would be
> awfully handy if sort had a 'Numeric sum' option ("-N" -- preferred
> '-s', but it's already taken) to go with the -h sorting:
>
<...>
> > du -sh *|sort -h|tail
A slightly different approach would be to defer the "human" size to later,
and enable to do any calculation you want manually, then convert to human sizes with "numfmt":
du -s * \
| sort -n \
| awk '{ sum+=$1 ; print } END { print sum, "Total" }' \
| numfmt --to=iec
One more thing: instead of 'du -s *', perhaps 'du -d1' would work better (depending on your needs), as it will print sizes used only by directories.
- assaf
This bug report was last modified 6 years and 213 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.