Command Line – Get Files Modified on a Specific Date

command linedatefind

Is it possible to find all php files within a certain directory that have been modified on a certain date

I'm using

find /var/www/html/dir/ -mtime -28 | grep '\.php' 

to get files modified within the last 28 days, but I only need files that have been modified on the following date: 2011-02-08

Best Answer

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?

Related Question