egrep
Quick Reference
Command Name:
egrep
Category:
file management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
Complex pattern matching
Search for complex patterns using extended regular expressions
- 2
Multiple pattern search
Search for multiple patterns in a single command using alternation
- 3
Code analysis
Find and analyze code patterns across multiple files
- 4
Log file parsing
Extract specific information from log files using powerful regex
Syntax
egrep [options] pattern [file...]
Options
Option | Description |
---|---|
-i |
Ignore case distinctions in patterns and data |
-v |
Select non-matching lines |
-n |
Display line numbers alongside the matched lines |
-c |
Count the number of matching lines instead of displaying them |
-l |
Print only the names of files containing matches |
-r, -R |
Recursively search through directories |
-w |
Match only whole words |
-A num |
Print num lines of trailing context after matching lines |
-B num |
Print num lines of leading context before matching lines |
-C num |
Print num lines of context around matching lines |
Examples
How to Use These Examples
The examples below show common ways to use the egrep
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.