System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

finding files modified last 30 days

 
himacs
Super Advisor

finding files modified last 30 days

Hi Admins,

I want to find files which modified last 30 days.Please tell me the options can be used with find and mtime options.

Regards
himacs
2 REPLIES
James R. Ferguson
Acclaimed Contributor

Re: finding files modified last 30 days

Hi:

Google this site and you would find any number of examples. In short:

# find /path -xdev -type f -mtime -30 -exec ls -ld {} +

...to find files in '/path' modified during the last 30-days.

Change '-30' to '+30' if you want files not modified in the last 30-days.

You can also touch two temporary files and use their timestamps as boundaries, like:

# touch -amt 201101010000 /tmp/f1
# touch -amt 201104010000 /tmp/f2

# find /patch -xdev -type f \( -newer /tmp/f1 -a ! -newer /tmp/f2 \) -exec ls -ld {} +

...to find files modified between the two periods.

Regards!

...JRF...
Victor Fridyev
Honored Contributor

Re: finding files modified last 30 days

find /directory -type f -mtime -30

HTH
Entities are not to be multiplied beyond necessity - RTFM