--- Begin Message ---
Subject: |
du feature request |
Date: |
Wed, 27 Jul 2011 22:06:52 -0400 |
perhaps I just need to learn the right switches to apply to sort on the
other side of a pipe, but I have often wanted to sort the results of du
in descending order and have it get it how to parse the -s(ummary) -h
(uman) readable output.
So instead of:
$ du -sh /var/log/*
28K /var/log/apt
76K /var/log/auth.log
4.0K /var/log/boot
4.0K /var/log/daemon.log
36K /var/log/dmesg
4.0K /var/log/dpkg.log
12K /var/log/fsck
1.8M /var/log/installer
4.0K /var/log/kern.log
0 /var/log/mail.err
36K /var/log/mail.info
36K /var/log/mail.log
0 /var/log/mail.warn
4.0K /var/log/messages
40K /var/log/partimage
16K /var/log/syslog
You'd have instead . . .
$ du -sh --sort-order=desc /var/log/*
1.8M /var/log/installer
76K /var/log/auth.log
40K /var/log/partimage
36K /var/log/mail.info
36K /var/log/mail.log
16K /var/log/syslog
36K /var/log/dmesg
28K /var/log/apt
12K /var/log/fsck
4.0K /var/log/boot
4.0K /var/log/daemon.log
4.0K /var/log/dpkg.log
4.0K /var/log/kern.log
4.0K /var/log/messages
0 /var/log/mail.err
0 /var/log/mail.warn
--
Hugh Esco
678-921-8186 x21
YourMessageDelivered.com
Keeping Your Group in the Loop
No Matter How Large or How Small
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#9187: du feature request |
Date: |
Thu, 28 Jul 2011 13:15:18 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11 |
tag 9187 notabug
thanks
On 07/27/2011 08:06 PM, Hugh Esco wrote:
perhaps I just need to learn the right switches to apply to sort on the
other side of a pipe, but I have often wanted to sort the results of du
in descending order and have it get it how to parse the -s(ummary) -h
(uman) readable output.
Rather than bloat du with additional --sort-order parameters, which will
never meet everyone's needs, it's better to make the standard sort able
to generically handle du -h output just like any other sort column. So
much so that in fact, we've already done it, by adding -h to sort.
$ du -sh /var/log/*
You should be pleased with:
du -sh /var/log/* | sort -k1,1h
(You may need to upgrade to coreutils 7.5 or newer)
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
--- End Message ---