Linux command to find files changed in last n seconds. Please suggest shell script,that we can run from cli or command.

link|improve this question
feedback

migrated from stackoverflow.com Jun 21 '11 at 17:47

This question came from our site for professional and enthusiast programmers.

4 Answers

Use find command like this:

find . -name "*.txt" -mtime -60s

To find all *.txt files modified in last 60 seconds.

link|improve this answer
Explicitly, "files modified between 0 and 60 seconds ago." – dannysauer Jun 21 '11 at 19:27
feedback

Similar to what glenn suggested, if you want to find everything modified, say, in the time during which an installer process was running, it might be easier to do something like:

touch /tmp/checkpoint
<do installer stuff>
find / -newer /tmp/checkpoint

Then you don't have to do the time calculation; you just find things changed after the checkpoint file.

link|improve this answer
feedback

If you're monitoring a directory for changes to files, you probably want to use inotify-tools instead of some infinite polling loop.

link|improve this answer
feedback

If you have a version of find that doesn't support -mtime -60s then a better solution is

touch -d '-60 seconds' /tmp/newerthan
find . -name "*.txt" -newer /tmp/newerthan
link|improve this answer
feedback

Your Answer

 
or
required, but never shown