rur*_*uni 18 linux bash diff command-line find
我有一个文件列表file.lst.现在我想查找目录dir中超过7天的所有文件,除了file.lst文件中的文件.如何修改find命令或file.lst从结果中删除所有条目?
例:
file.lst:
a
b
c
Run Code Online (Sandbox Code Playgroud)
执行:
find -mtime +7 -print > found.lst
Run Code Online (Sandbox Code Playgroud)
found.lst:
a
d
e
Run Code Online (Sandbox Code Playgroud)
所以我的期望是:
d
e
Run Code Online (Sandbox Code Playgroud)
dog*_*ane 26
管理您的find命令grep -Fxvf:
find -mtime +7 -print | grep -Fxvf file.lst
Run Code Online (Sandbox Code Playgroud)
标志意味着什么:
-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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7002 次 |
| 最近记录: |