0

What's the difference between egrep and grep ?

I've been search for a while online and can't find anything concise.

Are they the same except that egrep has some extended regexp features? Thanks

Freddy
  • 25,172
  • 1
  • 21
  • 60
Gpc
  • 1
  • 1
    See also [Why does my regular expression work in X but not in Y?](https://unix.stackexchange.com/questions/119905/why-does-my-regular-expression-work-in-x-but-not-in-y) for a brief description of the differences between basic regular expressions (BRE, `grep`) and extended regular expressions (ERE, `grep -E`/`egrep`) – ilkkachu Aug 10 '21 at 21:01

2 Answers2

0

On my RHEL 8 system:

$ ls -la /usr/bin/egrep
-rwxr-xr-x. 1 root root 28 Aug 12  2018 /usr/bin/egrep
$ file /usr/bin/egrep
/usr/bin/egrep: POSIX shell script, ASCII text executable
$ cat /usr/bin/egrep
#!/bin/sh  
exec grep -E "$@"

So, yes - egrep is simply a wrapper around grep that turns on the extended regexp features.

John
  • 16,759
  • 1
  • 34
  • 43
0

Extract from man page on Debian Gnu/Linux

       ... the variant programs egrep, fgrep and rgrep are the same
       as grep -E, grep -F, and grep -r,  respectively.   These  variants  are
       deprecated, but are provided for backward compatibility.
ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102