Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix grep-l和grep-ln_Unix_Grep - Fatal编程技术网

Unix grep-l和grep-ln

Unix grep-l和grep-ln,unix,grep,Unix,Grep,根据grep的手册 -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. grep-l,这似乎很好,因为

根据grep的手册

-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.
grep-l
,这似乎很好,因为当找到匹配项时,包含匹配项的文件名会被回显

然而,当我执行
grep-ln
时,grep会回显事件的每一行


grep-l
是否真的意味着在找到匹配的第一个匹配项时停止并停止扫描,而
grep-ln
将忽略
-l
标志?

这些选项不兼容。如果要在每个文件中显示第一个匹配(并且仅显示第一个匹配)的行号,请使用
grep-Hnm 1

-H,--带文件名 打印每个匹配的文件名

-n,--行号
在输出的每一行前加上输入文件中的行号

-m NUM,--max count=NUM
在NUM匹配行之后停止读取文件