using egrep to get result

Hi all,

Can egrep using AND OR ?, like egrep -i "title.$1" AND "category.$2" ./home....

I want to give two search criteria, the files where egrep is seaching in for example
looks like below rows.
title this is an test
category space

(command line input)
$1 script.sh this space

thanks

With egrep:

search for $var1 OR $var2:

egrep "[$var1]|[$var2]" file  

search for $var1 AND $var2:

egrep "$var1.*$var2|$var2.*$var1" file

Regards

Thank you, that's exact what i need.

Actually the examples are wrong. But this is a duplicate of another thread; see Need Help with Simple Regex - Page 3

Hi Era,
thank you very much, this should be the solution? var1.*var2|var2.*var1, should this create the AND?

Yes, that checks for var1 and var2 on one and the same line, in any order.

thanks Era, just what i was looking for.