Tools

grep

Search text with patterns — flags, regex modes, and context lines.

Usage

grep pattern fileBasic search
grep -r pattern dir/Recursive search
grep pattern *.txtMultiple files
cat file | grep patternPipe input

Matching

-iCase-insensitive
-vInvert (non-matching lines)
-wWhole word match
-xWhole line match
-e patternExplicit pattern
-f filePatterns from file

Regex mode

-EExtended regex (like egrep)
-FFixed strings, no regex
-PPerl-compatible regex
-GBasic regex (default)

Output

-cCount matching lines
-lFilenames only
-nShow line numbers
-oPrint only the match
-qQuiet (exit code only)
-m NUMStop after NUM matches
--colorHighlight matches

Context lines

-A NUMNUM lines after match
-B NUMNUM lines before match
-C NUMNUM lines around match