How to find the 10 largest file or directories in Linux


This finds the largest 10 files :

find . -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}

This finds the largest 10 directories:

find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}

You can easily change -10 to -n where n is the number of files/directories you are trying to find.

No comments:

Post a Comment