9

I can use

find . -mmin -5

to find files changed in last 5 minutes. However, if I try to find files with modification time in the future by giving negative number find refuses to do it:

find . -mmin --1

Is there a way to give future modification time to the standard Linux find?

1 Answer 1

9

To find files modified at least 5 days in the future, use:

find . -newermt "5 days"

The syntax for the time specification corresponds to the one for date -d. See man find for info on the switch named -newerXY for more information.

It is not possible to use e.g. -mmin to do this. It was reported as a bug against GNU find, and was solved by implementing -newerXY in findutils 4.3.3 (~2007) as I showed above.


Apparently it was not GNU find that was used, but BusyBox.

You should then be able to create a temporary file with touch -d and a date in the future and then use the -newer switch for find such as:

touch -d "+5 days" tmpfile
find . -newer tmpfile

BusyBox touch does not support that date format, but the principle is the same and its find supports -newer. Creating the reference file with a correct date is left as an exercise for the reader (always convenient to write).

3
  • Thanks. My problem is that my find is old embedded BusyBox find and not binutil find. Apparently standard linux way does not work here. :(
    – Muxecoid
    Commented Apr 24, 2012 at 14:51
  • @Muxecoid: I updated my answer with some BusyBox remarks. Commented Apr 24, 2012 at 15:09
  • This just saved me trouble on a new machine where I had done something ten hours in the future by accident (timezone offset applied to an already-offset hardware clock) and after fixing the clock a configure script complained about things being in the future (by an hour and a half or so still): find . -newermt '1 hour' | xargs touch -d '-9 hours' and I can continue. :-) Commented May 20, 2014 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .