根据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 -ln忽略-l标志时,grep -l真的意味着在找到第一个匹配项时停止扫描并停止扫描吗?
发布于 2011-08-04 10:58:18
这些选项不兼容。如果要显示每个文件中第一个匹配项(且仅显示第一个匹配项)的行号,请使用grep -Hnm 1。
文件名,--带文件名的-H
打印每个匹配项的文件名。
行号,----n
在输出的每一行前面加上其输入文件中的行号。
NUM,--max-count=NUM的-m
在NUM匹配行之后停止读取文件。
https://stackoverflow.com/questions/6935695
复制相似问题