Add this alias line to your command line environment (.profile, .bashrc, …) to quickly see the total size and find and sort the top 10 largest files and directories in your current path. I like to keep things simple and don’t let it recurse directories, but of course you can easily adjust its behavior. :)
Drop the sudo when you’re not an admin.
alias dud='sudo du -ahd 1 | sort -hr | head -n 11'
65M . 46M ./oud 17M ./flickr 1.3M ./Saree.jpg 1.2M ./Pinstripe.jpg 364K ./photos 136K ./error_log 80K ./wacu.jpg 28K ./wackywheels 24K ./spyro_avatar2.png 20K ./m
|du -ahd 1||Disk usage, -a is files and dirs, -h is human size, -d 1 is max depth 1.|
|sort -hr||Sort lines, -h parse human size, -r is reversed order.|
|head -n 11||Only output the first 10 lines. (output includes grand total line)|
I use this alias a lot on my Ubuntu and Debian servers. For Mac OSX I have not found a useful solution yet. The default command-line tools are very limited, its sort can’t parse human sizes.
OSX Update 2013-07-12:
After messing around with the OSX tools a bit more I decided to write my own script in PHP, which is properly installed by default. Just save the code from this gist (raw) to a file somewhere, make it executable with
chmod +x theSavedFile and add to your .bash_profile: