我正在使用下面的命令来查找包含字符串的所有文件,但它不仅显示文件,还显示字符串所在的行..
rgrep "foobar" .
如何只显示文件名(包含路径)?
答案 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.)