grep: Basic vs Extended

1 
1 3.6 Basic vs Extended Regular Expressions
1 =========================================
1 
1 In basic regular expressions the meta-characters ‘?’, ‘+’, ‘{’, ‘|’,
1 ‘(’, and ‘)’ lose their special meaning; instead use the backslashed
1 versions ‘\?’, ‘\+’, ‘\{’, ‘\|’, ‘\(’, and ‘\)’.
1 
1    Traditional ‘egrep’ did not support the ‘{’ meta-character, and some
1 ‘egrep’ implementations support ‘\{’ instead, so portable scripts should
1 avoid ‘{’ in ‘grep -E’ patterns and should use ‘[{]’ to match a literal
1 ‘{’.
1 
1    GNU ‘grep -E’ attempts to support traditional usage by assuming that
1 ‘{’ is not special if it would be the start of an invalid interval
1 specification.  For example, the command ‘grep -E '{1'’ searches for the
1 two-character string ‘{1’ instead of reporting a syntax error in the
1 regular expression.  POSIX allows this behavior as an extension, but
1 portable scripts should avoid it.
1