Reputation: 689
I am trying filter out couple of blocks of text that keep repeating over and over in my log file. For eg;
grep -v ("string one that I don't want" \| "string two that I don't want") file.log
I tried several variations of this and tried tweaking the white spaces . Sometimes it will filter out the first string sometimes neither. What will be the correct format to filter out more than one block of text using grep ?
Upvotes: 52
Views: 26208
Reputation: 785256
You can use -e
option multiple times in grep
to skip multiple search items:
grep -v -e "string one that I don't want" -e "string two that I don't want" file.log
OR else use regex
using grep -E
for extended regex support:
grep -vE 'string one|string two' file.log
Upvotes: 103