Basic vs extended regex in grep

With basic regex expressions (short BRE), special characters must be preceeded with a backslash if they are to be interpreted as special. Otherwise, they are interpreted as regular characters. The exception to this rule is the carrot character (^). BRE mode is activated with the -e option.

Let us consider a sample file /tmp/test.log":

Wassim@linux:/tmp$ cat test.log
a+b
a plus b
aaaaaaaab
Wassim@linux:/tmp$ 

Example 1: grep -e and passing the special characters without a backslash: