How do I grep and show the preceding and following 5 lines surrounding each matched line?
How do I grep and show the preceding and following 5 lines surrounding each
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For BSD or GNU
grepyou can use-B numto set how many lines before the match and-A numfor the number of lines after the match.If you want the same number of lines before and after you can use
-C num.This will show 3 lines before and 3 lines after.