Wednesday, October 21, 2015

Search for results excluding a word

To search for something excluding a certain word or phrase, use
grep -v "word" <file or location>
For example, the results of a grep search can include a lot of results which are not relevant. Eliminate those by using grep -v

 grep "blah" filename | grep -v "foo"

This will get you results with "blah" but nothing with "blah" and "foo" in them. 
 
 

No comments:

Post a Comment