Search

The egrep command

Like grep but treating the pattern as an extended regular expression. Equivalent to grep -E.

Syntax

egrep <patrón> [archivo...]

Most useful options

-iIgnores upper and lower case
-vInverts: shows what does not match
-nNumbers the lines
-cCounts matches

Copy-ready examples

$ egrep 'root|alumno' /etc/passwdAlternation: one or the other
$ egrep '^a' /etc/passwdLines starting with a

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • If the pattern contains | or ., quote it so the shell does not interpret it.

Related commands

FAQ

Are egrep and grep -E the same?

Yes, egrep is a historical shortcut for grep -E.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course