return surrounding lines for each hit
I'm using grep in a search that returns significant false-positivies, and it's probably easier for me to identify the good results by inspection, than to write the much more complicated grep expression.
To do that, I need to see more than 1 line for each result.
Can I (How do i) instruct grep to return 1-2 lines above and below each match?
If you have GNU grep
, then:
grep -A 2 -B 2
or grep -C 2
-A
stands for after
-B
stands for before
-C
stands for context (both before and after)
Source and more options: http://unixhelp.ed.ac.uk/CGI/man-cgi?grep
链接地址: http://www.djcxy.com/p/19630.html上一篇: 高级grep unix
下一篇: 为每次击中返回周围线路