grep show lines before and after code example
Example 1: lines before and after grep
You can use the -B and -A to print lines before and after the match.
grep -i -B 10 'error' data
Will print the 10 lines before the match, including the matching line itself.
Example 2: grep show lines above and below
grep -C 3 foo README.txt