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?
Add a comment
|
2 Answers
man find
-mmin
File's data was last modified n minutes ago.
-
also see Tometzsk'y answer to serverfault.com/questions/88222/…– PaulCommented 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– PaulCommented Feb 16, 2010 at 19:07
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
-
This trick is great when you need to find stuff modified by running a command (
touch timestamp && (some command) && find ...
)– voretaq7Commented Feb 16, 2010 at 17:28