Expression grouping

You can use parentheses () to group characters or words to make them one piece in the eyes of the regex engine:

$ echo "welcome to shell scripting" | awk '/(shell scripting)/{print $0}'$ echo "welcome to bash scripting" | awk '/(shell scripting)/{print $0}'$ echo "welcome to shell scripting" | sed -r -n '/(shell scripting)/p'$ echo "welcome to bash scripting" | sed -r -n '/(shell scripting)/p'

Since the shell scripting string is grouped with parentheses, it will be treated as a single piece.

So, if the entire sentence doesn't exist, the pattern will fail.

You may have realized that you can achieve that without parentheses ...

Get Mastering Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.