The pipe character

The pipe character (|) tells the regex engine to match any of the passed strings. So, if one of them exists, that is enough for the pattern to match. It's like a logical OR between the passed strings:

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

All ...

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.