Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Source: http://superuser.com/questions/9847/linux-utility-for-finding-the-largest-files-directories
- To find the largest 10 files (linux/bash):
- find . -type f -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
- To find the largest 10 directories:
- find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}
- To find the largest 10 directories (centos)
- du -a /var | sort -n -r | head -n 10
- Human-readable format
- cd /path/to/some/where
- du -hsx * | sort -rh | head -10
- From Mohan
- du -h . --max-depth=2 | sort -hr | sed -e 's/$/|/g'
- Find top 5 largest log files
- du -ha /var/log/* | sort -rh | head -n 5
- -h = Print sizes in human readable format (e.g., 10MB)
- -a = Displays all files and folders
- -S = Do not include size of subdirectories
- -s = Display only a total for each argument
- -c = Displays total amount of space used
- -k = Displays the file size in kilobytes
- -m = Displays the file size in megabytes
- sort = sort lines of text files
- -n = Compare according to string numerical value
- -r = Reverse the result of comparisons
- -h = Compare human readable numbers (e.g., 2K, 1G)
Advertisement
Add Comment
Please, Sign In to add comment