LinuxCommandLibrary

egrep

TLDR

Search for pattern in file

$ egrep "[pattern]" [file.txt]
copy
Search case-insensitive
$ egrep -i "[pattern]" [file.txt]
copy
Search with line numbers
$ egrep -n "[pattern]" [file.txt]
copy
Search recursively
$ egrep -r "[pattern]" [directory]
copy
Search for multiple patterns
$ egrep "[pattern1|pattern2]" [file.txt]
copy
Count matches
$ egrep -c "[pattern]" [file.txt]
copy
Show only matching filenames
$ egrep -l "[pattern]" [*.txt]
copy

SYNOPSIS

egrep [options] pattern [file...]

DESCRIPTION

egrep searches files for lines matching an extended regular expression pattern. It's equivalent to `grep -E` and supports ERE syntax including +, ?, |, and () without escaping.
Extended regular expressions are more readable than basic grep patterns for complex matches. Alternation (|), grouping (), and quantifiers work directly without backslashes.
egrep is deprecated in favor of `grep -E` but remains widely available for compatibility.

PARAMETERS

PATTERN

Extended regular expression.
FILE
File(s) to search.
-i
Case-insensitive search.
-n
Show line numbers.
-r, -R
Recursive search.
-l
Show only filenames.
-c
Count matching lines.
-v
Invert match (non-matching lines).
-o
Show only matched parts.
--help
Display help information.

CAVEATS

Deprecated - use grep -E. Behavior may vary between implementations. Large files may be slow. Binary files may produce garbage output.

HISTORY

egrep was originally a separate program with extended regex support. Modern grep includes this functionality with the -E flag, making standalone egrep redundant but preserved for compatibility.

SEE ALSO

grep(1), fgrep(1), sed(1), awk(1)

Copied to clipboard