eon*_*eon 35 linux text-processing find
如何在Linux上找到不包含某些文本的文件?基本上我正在寻找以下的反转
find . -print | xargs grep -iL "somestring"
Run Code Online (Sandbox Code Playgroud)
seh*_*ehe 59
你引用的命令,具有讽刺意味的是,你完全按照你的描述.测试一下!
echo "hello" > a
echo "bye" > b
grep -iL BYE a b
Run Code Online (Sandbox Code Playgroud)
只说一个.
我想你可能会混淆-L和-l
find . -print | xargs grep -iL "somestring"
Run Code Online (Sandbox Code Playgroud)
是反的
find . -print | xargs grep -il "somestring"
Run Code Online (Sandbox Code Playgroud)
顺便说一下,考虑一下
find . -print0 | xargs -0 grep -iL "somestring"
Run Code Online (Sandbox Code Playgroud)
甚至
grep -IRiL "somestring" .
Run Code Online (Sandbox Code Playgroud)
您可以单独使用 grep 来完成(无需查找)。
grep -riL "somestring" .
Run Code Online (Sandbox Code Playgroud)
这是对使用的参数的解释 grep
-L, --files-without-match
each file processed.
-R, -r, --recursive
Recursively search subdirectories listed.
-i, --ignore-case
Perform case insensitive matching.
Run Code Online (Sandbox Code Playgroud)
如果你使用l
小写,你会得到相反的结果(匹配的文件)
-l, --files-with-matches
Only the names of files containing selected lines are written
Run Code Online (Sandbox Code Playgroud)