29
14
I am trying to build a grep search that searches for a term but exludes lines which have a second term. I wanted to use multiple -e "pattern"
options but that has not worked.
Here is an example of a command I tried and the error message it generated.
grep -i -E "search term" -ev "exclude term"
grep: exclude term: No such file or directory
It seams to me that the -v
applies to all search terms / patterns. As this runs but then does not include search term
in results.
grep -i -E "search term" -ve "exclude term"
Is there any other option for exclude, as sometimes we have to grep lines around a word and If we exclude in the next operation using '|' , it just removes that word but doesn't remove the block for that word – Learner – 2018-12-06T17:12:14.193