If we wanted to talk properly about grep, an entire book would not be enough. grep supports many engines along with BRE and ERE. It supports engines such as Perl-compatible regular expression (PCRE).
The grep is a very powerful tool that most system administrators use every day. We just want to enlighten the point of using BRE and ERE patterns as we did with sed and AWK.
grep tool understands BRE patterns by default, and if you want to use ERE patterns, you should use the -E option.
Let's work with the following example file and use a BRE pattern:
Welcome to shell scripting.
love shell scripting.
shell scripting is awesome.
Let's test a BRE pattern:
$ grep '.sh' myfile
The results are colored in red.
Let's test an ERE pattern:
$ grep -E 'to+' myfile
All other ERE characters can be used in the same way.