Tuesday, February 7, 2012

How to display the top x biggest folder under unix linux

As the titles mentions here's a little one liner when you want to find out who's are the top disk space users under a certain directory:

du -sk * | sort -nr | cut -f2 | head -5 | xargs du -sh

The command above show the top 5 offenders in a nice readable way (i.e not in kb which i find hard to read):
$ du -sk * | sort -nr | cut -f2 | head -5 | xargs du -sh
 3.2G   Offender1
 1.8G   Offender2
 1.3G   Offender3
 1.1G   Offender4
 603M   Offender5