How to make "grep" read patterns from a file?
Suppose there is a large text file and I would lik开发者_开发技巧e to print only the lines that do not match some patterns. Obviously, I can use egrep -v 'patter1|pattern2|pattern3
. Now what if all those patterns are in a text file ? What is the best way to make egrep
read patterns from the file ?
grep -v -f pattern_file
egrep has an -f
option which does exactly that: you specify a file, and it reads patterns from that file, one per line.
精彩评论