Freenerd
See surrounding lines in grep

When you search for something with grep, you sometimes need some context for the search results. Use the following arguments for that:

grep -B 2 foo bar.txt # 2 lines before every match
grep -A 3 foo bar.txt # 3 lines after every match
grep -C 1 foo bar.txt # 1 line before and after every match
grep -n 1 foo bar.txt # 1 line before and after every match