| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

How to find files modified between specified dates and times

Page history last edited by Paul G. Taylor 9 years, 11 months ago

This How-to is based on an answer to this question,

 

How to list files that were changed in a certain range of time?

 

Generally speaking, when you're looking for files in a directory and its subdirectories recursively, use find.

The easiest way to specify a date range with find is to create files at the boundaries of the range and use the -newer predicate.

 

touch -t 201112220000 start
touch -t 201112240000 stop
find . -newer start \! -newer stop

 

 

The additional information that I am adding is that the trailing '0000' represents hours and minutes which can therefore be specified.  

 

So to find any files that were modified between 1200 noon and 1300 on a given day, say 2014-05-30, simply use

 

touch -t 201405301200 start
touch -t 201405301300 stop
find . -newer start \! -newer stop

There is precision to work within a two-minute time frame which should be sufficient for most purposes.

 

According to the man file for 'touch' the precision can be extended even to seconds : --

 

-t STAMP
              use [[CC]YY]MMDDhhmm[.ss] instead of current time

 Note that the -d and -t options accept different time-date formats.

DATE STRING
       The  --date=STRING  is  a  mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday".  A date
       string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers.  An empty string indicates the  beginning
       of the day.  The date string format is more complex than is easily documented here but is fully described in the info documentation.

For further information try 'info touch'

 

`-t [[CC]YY]MMDDHHMM[.SS]'
     Use the argument (optional four-digit or two-digit years, months,
     days, hours, minutes, optional seconds) instead of the current
     time.  If the year is specified with only two digits, then CC is
     20 for years in the range 0 ... 68, and 19 for years in 69 ... 99.
     If no digits of the year are specified, the argument is
     interpreted as a date in the current year.  Note that SS may be
     `60', to accommodate leap seconds.

Comments (0)

You don't have permission to comment on this page.