A Note on Grep

Match pattern1 AND pattern2, but NOT pattern3

ordered:

$ grep -E ‘pattern1.*pattern2’ filename | grep -Ev ‘pattern3’

unordered:

$ grep -E ‘pattern1’ filename | grep -E ‘pattern2’ | grep -Ev ‘pattern3’

Match pattern1 OR pattern2, but NOT pattern3 in the same line:

$ grep -E ‘pattern1|pattern2’ filename | grep -Ev ‘pattern3’

grep -E = egrep = match everwhere