Tuesday, May 28, 2013
CentOS - Check for large files & directories
FILES
Check for large files over 9 MB in the file system, in this example /home :
find /home -type f -xdev -size +9000000c -exec ls -ldh {} \;|sort -k 5n
- The xdev option tells it not to cross mount points.
- The exec option instructs the find command to issue an ls -ldh against any file that meets our criteria.
- The resulting matches are substituted inside the {}, and then executed.
- Then the results of the ls -ldh output is sent to the sort and sorted based on the 5th column which is the size column.
DIRECTORIES
du -H --max-depth=1 /home/ | sort -n -r