我可以使用什么简洁的命令来查找所有不包含文本字符串的文件?
我试过这个(使用 -v 来反转 grep 的参数)但没有运气:
find . -exec grep -v -l shared.php {} \;
Run Code Online (Sandbox Code Playgroud)
有人说这行得通:
find . ! -exec grep -l shared.php {} \;
Run Code Online (Sandbox Code Playgroud)
但它似乎对我不起作用。
这个页面有这个例子:
find ./logs -size +1c > t._tmp
while read filename
do
grep -q "Process Complete" $filename
if [ $? -ne 0 ] ; then
echo $filename
fi
done < t._tmp
rm -f t_tmp
Run Code Online (Sandbox Code Playgroud)
但这很麻烦,而且一点也不简洁。
ps:我知道这grep -L *会做到这一点,但是我真正想知道的是如何将 find 命令与 grep 结合使用来排除文件。
pss:我也不确定如何让 grep 包含带有grep -L *语法的子目录,但我仍然想知道如何使用它find …