Skip to main content
  1. Notes/

grep

Table of Contents
  • An stands for n lines “after” the match.
  • Bm stands for m lines “before” the match.

grep -A1 -B1 pattern file

If both numbers are the same, just use -C: grep -C1 yourpattern file

Grep multiple lines #

grep 'a\|b' abc.txt