grep Examples
[Overview]

grep Examples

grep - print lines matching a pattern

grep [OPTIONS] Pattern [File...]
grep [OPTIONS] -e Pattern -f File [File...]

-E: support extended regexp
-e <PATTERN>: Use <PATTERN> as pattern. Can be used multiple times (OR semantic)
-i: ignore case
-v: invert match 
-o: print only the matched part (output: one line per match)
-f: obtain patterns from file
-l: files with match
-w: The pattern must match whole words (surrounded by non word characters)
-L: files without match
-A <num>: Print <num> lines after matching context.
-B <num>: Print <num> lines before matching context.  
-m <num>: Stop reading a file after <num> matching lines. 
-c: suppress normal output, instead count matching lines.
--colour: highlight match
for further information see the manual page grep(1)


examples assembled by andreas schmidt for the KDIR-2022 conference