How to Find Files Modified in Last X Minutes (Find -Mmin Does Not Work as Expected)

How to find all the files created today and modified anytime before 5 minutes?

Since -daystart isn't that portible, consider a solution like so;

  1. Use $(date +"%H") to get the current hour, in your test case, this should be 10.

  2. Multiply that number by 60 to get the desired minutes

  3. Subtract 5 minutes to get the number of minutes between 00:00 and 09:55

  4. Use that value for the -mmin param

currentHour=$(date +"%H")
minutes=$(( 60 * currentHour - 5 ))
find . -mmin "-${minutes}" -mmin +5

Find files modified over 1 hour ago but less than 3 days

Find has -mtime and -mmin:

find . -mtime +3 -mmin -60

From the find manual:

Numeric arguments can be specified as:

+n for greater than n

-n for less than n

n for exactly n

Bash - How to find files that are not modified within a given time period?

Here's another approach (probably requires GNU coreutils)

touch -d "10 minutes ago" refFile
find . -type f -not -newer refFile

How to find files in ruby which were edited in some time interval?

You could get a list of files using Dir.[], and use File.mtime on each one to filter them:

Dir["*"].select { |fname| File.mtime(fname) > (Time.now - 60) }


Related Topics



Leave a reply



Submit