How to use exclude-patterns from a file

时间:2019-04-16 23:55:55

标签: awk

I want to use awk to search for pattern in multiple files but exclude some patterns from file

This is the code I have tried

BEGIN { print "Begin Processing of various Records"}
/Type.*ABC/ {a=1} /999/{a=0; if (a==1) print a;}
END { print "Process Complete" }

Examples:

This is the file example

Resources:
  CODE:
    Type: "ABC::DEF::AVC"
    Type: "ABC::DEF::999"
    Type: "ABC::DEF::ZZZ"

Now suppose I have file excludes with content

999
888
ZZZ

Now, I want to display all lines with match first pattern but excludes if any pattern from excludes is found.

2 个答案:

答案 0 :(得分:3)

这是您要做什么吗?

ACCOUNT_SIGNUP_FORM_CLASS = 'path.to.SignupForm' 

答案 1 :(得分:1)

如果您的数据位于“ d”文件中,请尝试使用gnu awk:

awk '/Type.*ABC/ && $0 !~ /999|888|ZZZ/' d