Skip to content

Instantly share code, notes, and snippets.

@fieldse
Created September 4, 2017 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fieldse/75cbe30bdcd29e2476b82aaa6a75e8fc to your computer and use it in GitHub Desktop.
Save fieldse/75cbe30bdcd29e2476b82aaa6a75e8fc to your computer and use it in GitHub Desktop.
Show lines before and after a matching string with grep

Grep to show the surrounding 2 lines before and after your match

grep 'some string to match' -B 2 -A 2 myfile.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment