3

find is a great tool for finding files. It has the option to find files that were modified in the last X days with -mtime. However I'd like something more fine grained than that. I want to be able to find files that were modified in the last 2 hours. Is there some way to make find (or some other similar tool) do this?

0

2 Answers 2

11

man find

-mmin

File's data was last modified n minutes ago.

2
  • also see Tometzsk'y answer to serverfault.com/questions/88222/…
    – Paul
    Feb 16, 2010 at 17:21
  • to be more verbose, find . -mmin -120 will find all files with an mtime within the past 2 hours
    – Paul
    Feb 16, 2010 at 19:07
4

An alternative to Paul Brewer's (best) answer: -newer. It essentially finds anything newer than a file. So you can use touch to create a timestamp for a file in the past, then see what's newer than that.

touch -t 201002160900 timestamp
find . -newer timestamp
1
  • This trick is great when you need to find stuff modified by running a command (touch timestamp && (some command) && find ...)
    – voretaq7
    Feb 16, 2010 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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