Monday, September 28, 2009

Find command examples and auto remove files/folders

Following command search for files which are not accessed since last 15 days:

find /path/to/base/directory/for/search -mtime +15

Use cmin instead of mtime in case you want to search in minutes

Following command search for files which are not accessed since last 2 minutes:

find /path/to/base/directory/for/search -cmin +2


Automatically remove files which are not accessed within last 15 days:

find /path/to/base/directory/for/search -mtime +15 -exec rm -rf {} \;

NOTE: {} these braces are having the result (files/folders) from first command ' find /path/to/base/directory/for/search -mtime +15 '.

No comments:

Post a Comment