grep [options] pattern [file]

cat [file] | grep [options] pattern

Main Options of grep

-i

Ignores case while searching.

grep -i "pattern" file.txt

-v

Inverts the match, showing lines that do not contain the pattern.

Searches recursively in directories.

grep -r "pattern" directory/

-**w**

Searches for whole words.

grep -w "pattern" file.txt

-E

Uses extended regular expressions.

grep -E "pattern|another" file.txt