Defining BRE patterns
To define a regex pattern, you can type the following:
$ echo "Welcome to shell scripting" | sed -n '/shell/p' $ echo "Welcome to shell scripting" | awk '/shell/{print $0}'

A very important thing you need to know about regex patterns in general is they are case sensitive:
$ echo "Welcome to shell scripting" | awk '/shell/{print $0}' $ echo "Welcome to SHELL scripting" | awk '/shell/{print $0}'

Note
Say you want to match any of the following characters:
.*[]^${}\+?|()
You must escape them with a backslash because these characters are special characters for the regex engines.
Now you know how to define a BRE pattern. Let's use the common BRE characters.
Anchor characters
Anchor characters are used to match the beginning or the end of a line. There are two anchor characters: the caret (^
) and the dollar sign ($
).
The caret character is used to match the beginning of a line:
$ echo "Welcome to shell scripting" | awk '/^Welcome/{print $0}'
$ echo "SHELL scripting" | awk '/^Welcome/...