Search files with extended regular expressions quickly and precisely from the shell. 10.03.2026 | reading time: 2 min egrep is the grep flavor that accepts extended regular expressions; use it to find complex text patterns fast in files or pipelines, and to combine alternation, grouping and quantified tokens with minimal escaping. Quick example Try this on a log file to find warnings and errors; the example shows a sample file, the exact `egrep` invocation and the output: ```bash Dec 10 10:00 server1 INFO User 42 logged in Dec 10 10:01 server1 WARN Disk space low Dec 10 10:02 server1 ERROR Unable to open file Dec 10 10:03 server2 INFO Heartbeat $ egrep -i -n '(error|warn)' server.log server.log:2:Dec 10 10:01 server1 WARN Disk space low server.log:3:Dec 10 10:02 server1 ERROR Unable to open file ``` Hands-on options Use `-n` to show line numbers, `-i` for case-insensitive matches, `-v` to invert match, `-o` to print only the matched text and `-c` to count matches; `egrep` is equivalent to `grep -E`, so scripts can switch to `grep -E` without changing regexes. Advanced patterns Leverage alternation with `|`, grouping with parentheses and quantifiers like `+` and `?` to express patterns such as `user([0-9]+)` or `err(or)?`; remember that some constructs like lookarounds are not supported by basic extended regex and need `grep -P` or a different tool. Where egrep fits egrep is excellent for quick, portable searches and for scripts that rely on POSIX-style extended regex; for very large codebases prefer modern, faster search tools but keep `egrep` in your toolbox for simple, reliable pattern matching. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting