How to grep 2 strings in Linux system

I am pretty sure I used grep command many times to grep two strings in Linux. See here is what I am trying:

dnf search pacakge | grep -i "string1|string2"
dnf search nginx | grep 'nginxnginx-mod-mail|nginx-mod-stream'

How do you grep 2 strings in CentOS Linux? What am I missing?

The syntax is invalid. Try escaping it

grep 'word-1\|word-2'
grep 'string-1\|string-2\|string-3'
grep [options] 'word-1\|word-2'
grep -i -w 'word-1\|word-2' fillename
command | grep -i -w 'word-1\|word-2'
## your dnf example with shell pipes ##
dnf search nginx | grep 'nginx-mod-mail\|nginx-mod-stream'

You should see something as follows but package version may differ as I am on Fedora:

nginx-mod-mail.x86_64 : Nginx mail modules
nginx-mod-stream.x86_64 : Nginx stream modules

The egrep command has much simpler syntax, but the grep works too as pointed out by @monk:

dnf search nginx | egrep 'nginx-mod-mail|nginx-mod-stream'

Fyi, you have typo too grep '**nginxnginx**-mod-mail|nginx-mod-stream' as nginxnginx. It should be a single word nginx, however you still need to the \| with grep.
Look into our guides:


And

That needs extended regex, so use grep -E
(or egrep, which is basically an alias to grep -E)

[...]  | grep -iE "string1|string2|string3"

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki