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

标签 linux unix find

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

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

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

提示:您的答案应符合提供的答案空间。

提示:使用 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? 中所述.

关于linux - 使用 find 命令查找文件修改时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33503846/

相关文章:

linux - 是否存在公开可用的部分解决方案来解析 *nix 样式的命令行选项而无需预先了解 key ?

c# - Unity - 在列表中找不到对象

replace - 如何在搜索字符串最后一次出现后的行上插入文本?

c - 在 C 中实现 shell

linux - SVN check out 失败并显示 "chunk delimiter was invalid"- 可以做什么?

linux - 使用 unixodbc 连接到 MS Access

linux - 在 windows 中编译 linux gcc - 在 windows 中使用 nvcc

linux - 计算csv文件的列数

directory - dokku - 我的应用程序目录在哪里

linux - LD_LIBRARY_PATH 似乎不起作用