查找不在列表中的文件 [英] find files not in a list
本文介绍了查找不在列表中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 file.lst
中有一个文件列表.现在我想查找目录 dir
中所有超过 7 天的文件,除了 file.lst
文件中的文件.如何修改 find 命令或从结果中删除 file.lst
中的所有条目?
I have a list of files in file.lst
.
Now I want to find all files in a directory dir
which are older than 7 days, except those in the file.lst
file. How can I either modify the find command or remove all entries in file.lst
from the result?
例子:
file.lst
:
a
b
c
执行:
find -mtime +7 -print > found.lst
found.lst
:
a
d
e
所以我的期望是:
d
e
推荐答案
通过 grep -Fxvf
传递 find
命令:
Pipe your find
command through grep -Fxvf
:
find -mtime +7 -print | grep -Fxvf file.lst
标志的含义:
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
-x, --line-regexp
Select only those matches that exactly match the whole line.
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing.
这篇关于查找不在列表中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文