如何grep在Linux上仅显示文件名(无内联匹配)?
grep
我通常使用类似:
find . -iname "*php" -exec grep -H myString {} \;
我如何才能获取文件名(带有路径)却没有匹配项?我必须使用xargs吗?我的grep手册页上没有找到执行此操作的方法。
xargs
标准选项grep -l(即小写的L)可以做到这一点。
grep -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在这种情况下,您也不需要。
-H