LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What is the difference between grep and egrep command (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-difference-between-grep-and-egrep-command-4175622298/)

winn 01-24-2018 05:14 AM

What is the difference between grep and egrep command
 
Hi I am new to Linux, can someone advise what is the difference between grep and egrep command.

syg00 01-24-2018 05:17 AM

The help for linux commands is the "man page" system.
"man grep" from a terminal will help. Use "q" (no quotes) to quit.

winn 01-24-2018 05:24 AM

Thanks a lot. Will do some research on that.

jlinkels 01-24-2018 06:30 AM

I can imagine the man pages are a bit overwhelming and do do really tell how to use grep. Grep and egrep is all about finding regular expressions.

Grep and egrep differ in how they handle regular expressions. Grep handles normal regular expressions, egrep handles extended regular expression syntax. Those are similar, but not identical. Extended regular expressions is a new definition which is not upward compatible with normal regular expressions. There is at least one case I know where a sequence in extended regular expression is the opposite of the same sequence in normal regular expression.

Differences between the two are pointed out here: https://www.regular-expressions.info/posix.html For more information on how to use grep, google for "regular expressions", not for grep.

grep -E is identical to egrep, it make grep to use extended regular expressions.

jlinkels


All times are GMT -5. The time now is 12:46 AM.