Multiple grep search/ignore patterns

command-line, grep, shell, unix

Solution

Just pipe your unfiltered output into a single instance of grep and use an extended regexp to declare what you want to ignore:

grep -Ri 64 src/install/ | grep -v -E '(\.svn|file|2\.5|2\.6)'

Edit: To search multiple files maybe try

find ./src/install -type f -print |\
    grep -v -E '(\.svn|file|2\.5|2\.6)' | xargs grep -i 64

Edit: Ooh. I forgot to add the simple trick to stop a cringeable use of multiple grep instances, namely

ps -ef | grep something | grep -v grep

Replacing that with

ps -ef | grep "[s]omething"

removes the need of the second grep.

Problem

I usually use the following pipeline to grep for a particular search string and yet ignore certain other patterns: ``` grep -Ri 64 src/install/ | grep -v \.svn | grep -v "file"| grep -v "2\.5" | grep -v "2\.6" ``` Can this be achieved in a succinct manner? I am using GNU grep 2.5.3.

Original source