Source From Here
Question
I would like to grep for a string, but also show the preceding five lines and the following five lines as well as the matched line. I'm scanning for errors in a logfile, and want to see the context.
How-To
For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match.
Question
I would like to grep for a string, but also show the preceding five lines and the following five lines as well as the matched line. I'm scanning for errors in a logfile, and want to see the context.
How-To
For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match.
沒有留言:
張貼留言