Showing posts with label sort. Show all posts
Showing posts with label sort. Show all posts
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.
Labels:
admin,
bash,
cut,
du,
Enterpise Linux,
find,
linux,
linux administraion,
script,
shell,
sort,
system admin,
tail,
unix,
xargs
Subscribe to:
Posts (Atom)