Rich
Rich

Reputation: 12653

grep a file with a list of regular expressions

I have a large file of regular expressions, one per line. I would like to inverse grep another multi-line file against any regular expression that appears in the first file. Something like this:

grep -v fileWithManyRegularExpressions fileThatMightMatchSomeRegularExpressions

Is there an elegant method to do this aside from looping through every regular expression?

Upvotes: 5

Views: 8816

Answers (2)

Jerry Coffin
Jerry Coffin

Reputation: 490128

At least with Gnu grep you can use --file=<filename> and all should be well.

Upvotes: 3

SilentGhost
SilentGhost

Reputation: 319601

grep -v -f regexes.txt content.txt

Upvotes: 14

Related Questions