DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far...

Welcome! This is a Q&A website for computer programmers and users alike, focused on helping fellow programmers and users. Read more

What are you stuck on? Ask a question and hopefully somebody will be able to help you out!
0 votes

I'm using grep for filtering a bunch of files. However, I need to remove exactly one pattern from the results. Like this

grep pattern FILES | ... do something ... | grep remove_pattern | ... do something ...

I can obviously replace remove_pattern with a regular expression but I prefer not to use them, if I can, in order to reduce complexity. Therefore I was wondering if there was an "opposite grep" that returns only the non-matching patterns, notgrep remove_pattern or something like that.


1 Answer

+2 votes
Best answer

Use the grep -v option.

selected by
Contributions licensed under CC0