DEV Community


Find files between two dates

Alain Mauri
Passionate dad and guitar player. Dev by mistake and Ruby lover
・2 min read

Find files between two dates

I’d like to share a simple way I’ve learned to find how many files have been created between two dates, using Linux command line. The method involves find command.


Working on a project that involved the creation of a lot of KOS objects (nothing difficult, just another DICOM object), I needed a quick and easy way to find out how many files my class method created.


I knew that find command could help, so I started digging into its manual and at the end I found the right option:

 -newerXY reference
Succeeds if timestamp X of the file being considered is newer than timestamp Y of the file reference. The letters X and Y can be any of the following letters:

              a   The access time of the file reference
              B   The birth time of the file reference
              c   The inode status change time of reference
              m   The modification time of the file reference
              t   reference is interpreted directly as a time

after many trials I ended up with newermt which is newer with sub-options X=m for modification date and Y=t for literal time.

At this point my “command” was taking shape:

find -type f -name "*.dcm" -newermt 2016-04-08 ! -newermt 2016-04-09

Last thing I needed to know, was the number of files that have been created in the desired date interval and this was the easiest part of the command:

wc -l

the command used prints the newline count.


find -type f -name "*.dcm" -newermt 2016-04-08 ! -newermt 2016-04-09 | wc


Discussion (0)