最佳答案
I have a file that possibly contains bad formatting (in this case, the occurrence of the pattern \\backslash
). I would like to use grep
to return only the line numbers where this occurs (as in, the match was here, go to line # x and fix it).
However, there doesn't seem to be a way to print the line number (grep -n
) and not the match or line itself.
我可以使用另一个正则表达式来提取行号,但我想确保grep本身不能执行此操作。我认为grep -no
最接近,但仍然显示匹配。