我如何使用grep来显示文件名(no in
  我如何使用grep在Linux上显示文件名(没有内嵌匹配)? 
我通常使用类似于:
find . -iname "*php" -exec grep -H myString {} ;
  我怎样才能得到文件名(带路径),但没有匹配?  我必须使用xargs吗?  我没有看到在我的grep手册页上做到这一点的方法。 
  标准选项grep -l (即小写的L)可以做到这一点。 
从Unix标准:
-l
    (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 。 
从grep(1)手册页: 
  -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.)
  对于简单的文件搜索,您可以使用grep的-l和-r选项: 
grep -rl "mystring"
所有的搜索都是由grep完成的。 当然,如果您需要选择其他参数上的文件,找到正确的解决方案:
find . -iname "*.php" -execdir grep -l "mystring" {} +
  execdir选项为每个目录构建每个grep命令,并将文件名只连接到一个命令( + )。 
