尝试使用
打印当前目录中的所有文件find . -newer myfile -mtime +3 ! -name . -prune
但它也打印子目录中的文件 试图在这里阅读相关的帖子:
How to use '-prune' option of 'find' in sh?
但不明白但尝试了
find . -newer myfile -mtime +3 ! -name . -prune -o -print
这也没有带来我想要的东西 也尝试了
find . -type f -newer myfile -mtime +3 ! -name . -prune
但是这会以递归方式将所有.snapshots子目录放在输出中。 请告诉我如何使用prune避免输出中的所有子目录。
输出
find . -newer myfile -mtime +3 ! -name . -prune
./.snapshot/hourly.7/file_status_out.txt
./.snapshot/hourly.1/file_status_out.txt
./.snapshot/hourly.6/file_status_out.txt
./.snapshot/hourly.5/file_status_out.txt
./.snapshot/nightly.0/file_status_out.txt
./.snapshot/hourly.0/file_status_out.txt
./.snapshot/hourly.4/file_status_out.txt
./.snapshot/hourly.2/file_status_out.txt
./.snapshot/hourly.3/file_status_out.txt
./.snapshot/nightly.2/file_status_out.txt
./.snapshot/nightly.1/file_status_out.txt
./.snapshot/veritas.nfs01p_vol1/file_status_out.txt
./.snapshot/weekly.0/file_status_out.txt
./.snapshot/lonnf30060(1874649454)_nfs01p_vol1.58917/file_status_out.txt
./.snapshot/lonnf30060(1874649454)_nfs01p_vol1.58916/file_status_out.txt
./.snapshot/dfpm_base(dataset-id-225039)conn1.0/file_status_out.txt
./file_status_out.txt
答案 0 :(得分:0)
这取决于" myfile"的最后修改时间,隐式查找带有表达式的-and
或-a
,因此修剪的路径是(目录文件)更新如果myfile最近修改时间超过3天,则myfile -newer myfile
和-mtime +3
可能无法在3天内更新。
如果不支持-maxdepth
,则修剪目录的另一种解决方案
find . ! -name . -type d -prune -o -print
可以在-o
find . ! -name . -type d -prune -o -newer myfile -print
更新以下评论,似乎没有在正确的地方添加条件:
find . ! -name . -type d -prune -o -newer myfile -mtime +1 -print
-prune
之前的条件是过滤子目录(键入d除外。否则不返回任何内容),-o
之后的条件是将文件过滤到-print
或-ls
取决于最后一个论点