我正在尝试回答这个问题:
使用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/