标准选项grep -l
(也就是小写的L)可以做到这一点。
From the Unix标准:
(The letter ell.) Write only the names of files containing selected lines to standard output. Pathnames are written once per file searched. If the standard input is searched, a pathname of (standard input) will be written, in the POSIX locale. In other locales, standard input may be replaced by something more appropriate in those locales.在这种情况下,你也不需要-H
。