grep multiple strings code example
Example 1: grep 2 matches or
Just use one of following forms with grep or egrep commands :)
grep "PATTERN1\|PATTERN2" FILE
grep -E "PATTERN1|PATTERN2" FILE
grep -e PATTERN1 -e PATTERN2 FILE
egrep "PATTERN1|PATTERN2" FILE
Example 2: bash print lines that match any of several words
grep 'word1\|word2\|word3' /path/to/file
Example 3: bash print lines that contain multiple specific words
grep first_word input_file | grep second_word
Example 4: grep in multiple files
grep -E 'fatal|error|critical|failure|warning|' *.log