Linux – When to use egrep instead of grep

bashlinux

I am preparing for a Linux terminal assessment now, I tried to Google and found most resources are referring to the basic "grep" rather than the more powerful "egrep" — well, that is at least what the professor said in lecture.

I am always working with small samples so performance tuning is a thing too far away.

So basically I'd like to know are there any areas where I must switch to egrep to do it in a better way? Is it safe to work with basic "grep" as for now? will there be potential risks?

Sorry about my limited knowledge on Linux shell commands, the man page looks like a maze to me and honestly I haven't put much time in understanding all the features both command provide.

Best Answer

egrep = grep -E

From http://www.opengroup.org/onlinepubs/007908799/xcu/grep.html

"Match using extended regular expressions. Treat each pattern specified as an ERE, as described in the XBD specification, Extended Regular Expressions . If any entire ERE pattern matches an input line, the line will be matched. A null ERE matches every line."

So, with egrep you can use +, ?, | and ().

Related Question