Linux – Using Find to Locate Files Older Than a Specific Date

findlinuxshell

find has good support for finding files the more modified less than X days ago, but how can I use find to locate all files modified before a certain date?

I can't find anything in the find man page to do this, only to compare against another files time or to check for differences between created time and now. Is making a file with the desired time and comparing against that the only way to do this?

Best Answer

If you have only '-newer file' then you can use this workaround:

# create 'some_file' having a creation date of 16 Mar 2010:
touch -t 201003160120 some_file

# find all files created after this date
find . -newer some_file

man touch:

  -t STAMP
          use [[CC]YY]MMDDhhmm[.ss] instead of current time

Assuming that your touch has this option (mine is touch 5.97).

Related Topic