‘find’ing files older than some date

‘find’ing files older than some date

I just wanted to capture this real quick. I’m sure most UNIX admin types have this cemented in their mind somewhere, but I always forget it:

# find . -ctime +1 -name "*.dbf" -print

I used the above command to find all .dbf ( -name “*.dbf” ) files in the current directory ( . ) that had their status changed ( file attributes ) more than one day ago ( -ctime +1 ). This also works to search for files that have been accessed more than one day ago ( -atime +1 ), or to check that the contents were changed more than one day ago ( -mtime +1 ).

You can also specify less than one day ago ( -ctime -1 ), or exactly one day ago ( -ctime 1 ).

So, the format for the time options is:

    * -mtime n
    * -ctime n
    * -atime n

where n is a number of days. The following applies:

    * A number with no sign, for example, 3 (as in -mtime 3 or -atime 3), means the 24-hour period that ended exactly three days ago (in other words, between 96 and 72 hours ago).
    * A number with a minus sign (-) refers to the period since that time. For example, -3 (as in -mtime -3) is any time between now and three days ago (in other words, between 0 and 72 hours ago).
    * Naturally, a number with a plus sign (+) refers to the 24-hour period before that time. For example, +3 (as in -mtime +3) is any time more than three days ago (in other words, more than 96 hours ago).

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s