Print list of folders sorted by their size
In order to print a list of folders and files sorted according to their size you only need two built-in UNIX commands, put together using the pipe (“|”):
du -h /var/www/ --max-depth=1 | sort -h
Whereas du gives you the storage space occupied by certain files and folders, sort actually sorts the resulting list. Using the additional parameter max-depth you can specify the folder depth which du will use to echo files and folders on the shell during its recursive parsing process.