grep
的选项是什么,它允许我只打印匹配的文件,而不打印文件中与条件匹配的行?
grep -l
(这是一个小写的L)
您可以使用 Unix 风格的
-l
开关 – 通常简洁而神秘 – 或等效的 --files-with-matches
– 更长且更具可读性。
grep --help
的输出不容易阅读,但它就在那里:
-l, --files-with-matches print only names of FILEs containing matches
-l
(这是一个小写的 L)。
还要记住一件事。非常重要。
您必须指定这样的命令才能更精确
grep -l "pattern" *