If you have a folder my/folder
, you can run
du -h my/folder | sort -rh | head -n 10
to get a list of the 10 largest subfolders.
Explanation:
du -h
: get the size of the elements in the folder in human-readable formatsort -rh
: sort human-readable in reverse order (requires an updated version ofsort
)head -n 10
: only take the first 10 elements
The tree
command also has built in support for showing file sizes: run tree --du
and the file sizes will be included in the directory listing.