使用 find 命令查找文件修改时间

Using find command to find file modification times

我正在尝试回答这个问题:

使用find命令统计/usr/include及其子目录在最近400天内累计修改了多少个以.h结尾的文件。您可以在您的解决方案中使用 wc。

要回答这个问题,请复制并粘贴您用来查找答案的确切命令。

提示:您的答案应该符合所提供的 space 答案。

提示:使用 man find 研究基于文件修改时间的查找命令。

到目前为止我正在使用:

find usr/include -name '*.h' -mtime -399 | wc

我会用这个

find /usr/include -type f -mtime -400 -name "*.h"
  • -type f 只检查文件
  • -mtime -400 使时间低于 400 天
  • -name "*.h" 名称以 h 结尾。

那就是统计出现次数的问题了

如果某些名称包含新行,您可能需要使用 -printf '.' | wc -c,如 bash - What is the best way to count find-results? 中所述。