Regular expression – GREP: How to search for, but simultaneously exclude some match

I need a way to simplify this command:

grep'SEARCHTERM' server.log | grep -v ' PHHIABFFH' | grep -v'Stats'

It should find all rows including SEARCHTERM, but exclude if one of the SEARCHTERM rows contains PHHIABFFH or Stats.

This will work:

grep'SEARCHTERM' server.log | grep -Ev'PHHIABFFH|Stats'

I need a way to simplify this command:

grep 'SEARCHTERM' server.log | grep -v'PHHIABFFH' | grep -v'Stats'

It should find all rows including SEARCHTERM, but exclude if one of the SEARCHTERM rows contains PHHIABFFH or Stats .

This will work:

grep'SEARCHTERM' server.log | grep- Ev'PHHIABFFH|Stats'

Leave a Comment

Your email address will not be published.