2

我在下面使用这个命令来查找所有包含字符串的文件,但它不仅显示文件,还显示字符串所在的行。

rgrep "foobar" .

如何只显示文件名(包括路径)?

4

1 回答 1

3

你需要 -l 选项

来自 grep 手册页:

-l, --files-with-matches
          Suppress  normal  output;  instead  print the name of each input file from which output would normally have been printed.  The scanning will stop on the
          first match.  (-l is specified by POSIX.)
于 2012-09-26T11:56:57.183 回答