Korean

egrep — Extended regex search

Linux / Basic Linux commands / egrep.html

Basic Linux commandsOriginalRegistered 2026-10-20T09:00:00+09:00

A grep variant that uses extended regular expressions.

Basic Information

Command Nameegrep
One-line IntroductionA grep variant that uses extended regular expressions.
Provided byGNU grep
Official Documentationhttps://man7.org/linux/man-pages/man1/grep.1.html
Supported Operating SystemsLinux, macOS (deprecated), BSD
Installation StatusInstalled by default
CategoryLinux basic commands (tags: Linux basic commands (tags: egrep, grep, regex, ERE))

What is this command?

egrep behaves like grep -E. Extended regex metacharacters such as +, ?, | and () work without backslashes.

Modern GNU grep discourages egrep and recommends grep -E. New scripts should use grep -E for portability and maintainability.

What problems does it solve?

  • Matching one of several alternatives
  • Specifying repetition counts with {n,m}
  • Combining groups and alternation
  • Understanding egrep calls in legacy scripts

Key features

Extended regex

Use +, ?, | and () without escaping.

  • When to use: Writing complex conditions concisely
  • What you get: Patterns become easier to read.
  • Limitations: Syntax differs from basic grep and can confuse.

Multiple patterns

Alternation matches several options at once.

  • When to use: Finding errors and warnings together
  • What you get: Reduces multiple calls to one.
  • Limitations: Without grouping, precedence may differ from intent.

Portability

Prefer grep -E for new code.

  • When to use: Maintaining scripts long term
  • What you get: Avoids deprecation warnings.
  • Limitations: Some very old systems only provide egrep.

Installation and usage

Check whether it is installed

egrep --version

sudo apt install grep # Debian/Ubuntu sudo dnf install grep # Fedora

Real-world examples

Alternation

Match either of two strings.

egrep 'error|warning' app.log

Repetition

Match three digits.

egrep '[0-9]{3}-[0-9]{4}' contacts.txt

Use grep -E

Run the same query with the recommended syntax.

grep -E '^(GET|POST) ' access.log | head