Getting all files that have been modified on a specific date

On recent versions of find (e.g. GNU 4.4.0) you can use the -newermt option. For example, to find all files that have been modified on the 2011-02-08

$ find /var/www/html/dir/ -type f -name "*.php" -newermt 2011-02-08 ! -newermt 2011-02-09

Also note that you don't need to pipe into grep to find php files because find can do that for you in the -name option.

Take a look at this SO answer for more suggestions: How to use 'find' to search for files created on a specific date?


Annoyingly, there isn't any direct way with standard find. Recent versions of find on GNU systems (e.g. non-embedded Linux, Cygwin) and some *BSDs have options such as -newermt to compare a file date with a spelled-out date.

With standard find, all you can do is compare the file date with the current date (-mtime) or with a fixed file. The current date is usually not useful in this case (it counts back from the time you run the find command, whereas most applications require a calendar date). That leaves you with the kludge of creating temporary files to define a range.

touch -t 201103070000 start.tmp
touch -t 201103080000 stop.tmp
find . -newer start.tmp \! -newer stop.tmp -print
rm start.tmp stop.tmp

With zsh you could use the function age to print only the names of files that have been modified on a certain date:

autoload age
print -rl -- *.php(.e:age 2011/02/08:)

or, if you want to search recursively:

autoload age
setopt extendedglob
print -rl -- **/*.php(.e:age 2011/02/08:)