如何只使用rgrep显示包含单词的文件(包含的路径)?

时间:2012-09-26 11:54:42

标签: bash

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

rgrep "foobar" .

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

1 个答案:

答案 0 :(得分:3)

你需要-l选项

来自grep man page:

-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.)