Grep with AND relation

Hi:

I don't know if this is the right forum for this question, but please, help me:

I know this grep sintax to find lines with stringa OR stringb in a file:

grep -E "stringa|stringb" file

Is there a specific sintax when I need to find lines with stringa AND stringb?

Thanks.

Mario./
multisitesAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jlevieConnect With a Mentor Commented:
grep -e "stringa.*stringb" should work. That says to return a match if a line contains stringa, zero or more intervening characters, and stringb.
0
 
Karl Heinz KremerCommented:
This only finds stringa and stringb if they occur in this order. What I usually do is to pipe multiple greps together:

grep stringa file | grep stringb
0
All Courses

From novice to tech pro — start learning today.