使用find查找8月份修改的文件

我需要find八月修改的文件。 这是我缩小修改时间的部分命令。 这工作,但似乎缺less一些文件。 我猜这是缺less在给定的小时或小时修改的文件,因为数字的变化取决于我运行这个脚本的一天的哪一部分。 我正在查看-mmin参数,但正在努力如何正确实施它。 我正在寻找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"; 

你可以用新的开关来-newer事情

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

这将find比文件start新的文件,而不是更新的文件end

新文件

  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 

您可以使用touch -t创build两个文件,代表持续时间的开始和结束。 然后,您可以使用-newer选项来find 。 详细的答案在这里 。