Monday, November 15, 2010

Find recent large files in Unix

One morning you log into a Unix server and find that one of the disk partitions is filled up. You wonder why, or perhaps, what caused it to fill up recently? The answer to this question is just a piece of cake.

Fire up Bash or your favorite shell and enter the following in the terminal:

find /home/r00tb0x/ -type f -mtime -2 -exec ls -ltrh "{}" ";"

This tells Unix to find all files (nodes of type 'f') which have been modified (created or appended to) in the last couple of days. The output will be sorted in chronological order with human readable format of the size field.

Similarly you can find old files by giving the mtime argument a positive value.
Post a Comment