开发者

How to make "grep" read patterns from a file?

开发者 https://www.devze.com 2023-03-27 03:34 出处:网络
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 t

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消