I did some simple tests with grep '+' and '*' special character
$ echo 'where wh+'> /tmp/toto
$ grep 'wh[e]\*' /tmp/toto
$ grep 'wh[e]*' /tmp/toto
where wh+
$ grep 'wh[e]+' /tmp/toto
$ grep 'wh+' /tmp/toto
$ grep 'wh[e]\+' /tmp/toto
where
$ grep -E 'wh[e]*' /tmp/toto
where wh+
$ grep -E 'wh[e]+' /tmp/toto
where wh+
From theses tests, non extended grep '+' (and '?') is not interpreted as a special character, in order to use it as a special character it must be escaped. As I read, grep uses Basic Regular Expressions (without -E option), in this case, special characters are defined here :
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03
and '?' '+' are not special characters for BRE.
But why does escaping non special character '+' in a BRE makes it special character?
Best Answer
This is a GNU extension. From the
grep(1)
manpage:and further down