Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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";
share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
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 {}\; –  Webnet Sep 27 '12 at 12:51
add comment

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
41597
sudo find /home -newer start -not -newer end | wc -l
41568
sudo find /home -newer end | wc -l
29
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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