Every once in a while I run the following command on my servers to hunt out the largest files to make sure nothing’s taking up too much space. For example, it’s been very useful in hunting down over sized log files or email accounts. It searches everything over 20MB and outputs the list to bigfiles.txt ordered by size (in MB) descending.
find / -type f -size +20000k -exec ls -la {} \; | sort +4 -nr | awk '{ printf "%-20s %s\n", $5/1048576, $9 }' > bigfiles.txt &
You can exclude a path by adding a little more to the command. The following will do the same as above but exclude the /backup directory:
find / -path '/backup' -prune -o -type f -size +20000k -exec ls -la {} \; | sort +4 -nr | awk '{ printf "%-20s %s\n", $5/1048576, $9 }' > bigfiles.txt &
You can also change the 20000k to whatever you want the smallest files to be.
It’s a fantastic little command and I just thought I’d share it with the world.
Additional comments powered by BackType
You can leave a response, or trackback from your own site. Follow any responses to this entry through the RSS 2.0 feed.
Recent Comments