Commands.app

grep

Text Processing

Search for patterns in files or output

Options & Flags
Available options for this command
-i

Case-insensitive search

-r

Recursive search in directories

-n

Show line numbers with matches

-v

Invert match (show non-matching lines)

-c

Count matching lines

Examples
Common usage examples

Search for 'pattern' in file.txt

grep 'pattern' file.txt

Recursively search for 'error' in log files (case-insensitive)

grep -ri 'error' /var/log/

Find nginx processes

ps aux | grep nginx
Notes
  • Supports regular expressions for complex pattern matching
  • Use quotes around patterns with spaces or special characters
Related Commands
You might also find these useful