Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 standard linux find?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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).

share|improve this answer
    
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 Apr 24 '12 at 14:51
    
@Muxecoid: I updated my answer with some BusyBox remarks. –  Daniel Andersson Apr 24 '12 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. :-) –  Chris Morgan May 20 at 15:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.