LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   grep: grep for two substrings? (https://www.linuxquestions.org/questions/linux-general-1/grep-grep-for-two-substrings-474881/)

eur0dad 08-17-2006 03:46 PM

grep: grep for two substrings?
 
I'm trying to get grep to return true if it finds string xyz or string abc. I know you can do it with individual chars, but can this be accomplished with substrings? If so, how?

I.e.:

if cat /file | grep "xyz or abc"; then
echo "string contains substring xyz or substring abc"
fi

KenJackson 08-17-2006 03:53 PM

Try:
Code:

if cat file | grep 'xyz\|abc'; then
    echo "string contains substring xyz or substring abc"
fi


eur0dad 08-17-2006 04:03 PM

Quote:

Originally Posted by KenJackson
Try:
Code:

if cat file | grep 'xyz\|abc'; then
    echo "string contains substring xyz or substring abc"
fi


Sweet. Thanks!


All times are GMT -5. The time now is 09:24 PM.