Sample Header Ad - 728x90

How do you sort du output by size?

302 votes
18 answers
338971 views
How do you sort du -sh /dir/* by size? I read one site that said use | sort -n but that's obviously not right. Here's an example that is wrong. [~]# du -sh /var/* | sort -n 0 /var/mail 1.2M /var/www 1.8M /var/tmp 1.9G /var/named 2.9M /var/run 4.1G /var/log 8.0K /var/account 8.0K /var/crash 8.0K /var/cvs 8.0K /var/games 8.0K /var/local 8.0K /var/nis 8.0K /var/opt 8.0K /var/preserve 8.0K /var/racoon 12K /var/aquota.user 12K /var/portsentry 16K /var/ftp 16K /var/quota.user 20K /var/yp 24K /var/db 28K /var/empty 32K /var/lock 84K /var/profiles 224M /var/netenberg 235M /var/cpanel 245M /var/cache 620M /var/lib 748K /var/spool
Asked by xenoterracide (61213 rep)
Dec 9, 2010, 11:17 AM
Last activity: Nov 25, 2020, 07:37 AM