8

I'm a newbie on regular expression and want to do some practicing with the 'grep' command. However, I have noticed that people have been using the following commands for rgx.

grep -E <regular expression pattern>
grep -P <regular expression pattern>
grep -e <regular expression pattern>
grep <regular expression pattern>

Can some one tell me what's the difference between them? I have look them up in "man" command and some simple googles, but either is too brief or too overwhelming to understand (e.g. what is 'perl style' or extended regular expression?).

serenesat
  • 4,611
  • 10
  • 37
  • 53
hackjutsu
  • 8,336
  • 13
  • 47
  • 87
  • Where do you see 'perl style'? – Deanie May 05 '15 at 06:08
  • This question already has good answers [here](http://unix.stackexchange.com/q/17949/102866) and [here](http://superuser.com/q/508881/416314). – serenesat May 05 '15 at 06:19
  • 6
    @tripleee This isn't a duplicate of the mentioned question because that question does not address `grep -P` – Christopher Bottoms Nov 06 '18 at 18:47
  • I added a second duplicate which has a wonky title but an answer which covers this in some more depth (which I should disclose is by yours truly). – tripleee Nov 07 '18 at 06:04
  • @serenesat Neither of those questions have answers which address `grep -P`. `pgrep` is process grep, not Perl grep. – Yehuda Sep 07 '22 at 13:57
  • Second link in my comment have an [answer](https://superuser.com/a/508882/416314) which explains about pgrep. – serenesat Sep 09 '22 at 06:34

0 Answers0