Skip to main content
2 of 5
added 58 characters in body
nisetama
  • 1.2k
  • 14
  • 7

If patterns.txt contains one pattern per line, you can do something like this:

awk 'NR==FNR{a[$0];next}{for(i in a)if(!match($0,i))next}1' patterns.txt -

To search for fixed strings instead of regular expressions, replace match with index.

To print all instead of no lines of the input in the case that patterns.txt is empty, replace NR==FNR with FILENAME==ARGV[1] or with ARGIND==1 in gawk.

nisetama
  • 1.2k
  • 14
  • 7