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
sort -h
worked for me in Ubuntu 16.04 LTS in Aug 2017. First I find my mounted drive bycd /mnt
(mounted by UUID in fstab). Then I dodu >~/dumnt.out
thensort -h ~/dumnt.out >~/dumntsort.out
then I can do `tail ~/dumntsort.out to see the largest space hogs. – SDsolar Aug 17 '17 at 08:25