bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20936: suggestion for a 'wart-ish' extension off of 'sort'


From: Assaf Gordon
Subject: bug#20936: suggestion for a 'wart-ish' extension off of 'sort'
Date: Tue, 30 Jun 2015 13:05:38 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]