I need to find files modified in August. Here's my portion of the command that narrows down the modification time. This works, but it seems to be missing some files. I'm guessing this is missing files modified in a given hour or hour(s) because the numbers change depending on what part of the day that I run this script. I'm looking at the -mmin parameter but am struggling with how to exactly implement it. I'm looking for all files modified between Aug 1 - 31.

    $dayOfMonth = date("j");
    $daysLastMonth = date("t", strtotime('-1 month'));
    $secondsSinceMidnight = time() - strtotime('00:00');
    $secondsUntilMidnight = (60*60*24) - $secondsSinceMidnight;
    $commandAppend = " -name '*.pdf' -mtime -".($dayOfMonth+$daysLastMonth)." -mtime +".($dayOfMonth)." | wc -l";

2 Answers 2


You could to something with the -newer switch

touch -d "01 AUG 2012" start
touch -d "31 AUG 2012 23:59:59" end
find /path -newer start -not -newer end

Which will find files that are newer than the file start and not newer that the file end

-newer file

          File was modified more recently than file.  If file  is  a  sym-
          bolic  link and the -H option or the -L option is in effect, the
          modification time of the file it points to is always used.
sudo find /home -newer start | wc -l
sudo find /home -newer start -not -newer end | wc -l
sudo find /home -newer end | wc -l

You can create two files using touch -t representing the start and end of your duration. Then, you can use find with -newer option. The detailed answered is here.

  • That gives me the error find: missing argument to -exec'` when I run find "/path-to-pdfs/" -name '*.pdf' -newer /script_files/tmpStartModificationTime ! -newer /script_files/tmpEndModificationTime -exec ls -s {}\;
    – Ben
    Sep 27, 2012 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.