regex - Match list of patterns in order in a file using awk -
i'd match list of newline-separated regular expressions against file, in order (that is, regex1 must matched before matching regex2), , succeed iff regular expressions matched. needs done in awk because don't have convenient access python , perl on said platform.
so file1 contain
address 0x[0-9]* disk [a-za-z]:\\
and file2 contain:
asm address 0xfae2222 jubkj disk c:\ aaa
in case, want script succeed.
i know it's possible perform action when matching pattern, eg '/pattern/{ print $0 }'
, don't think there's way indicate relationship between 2 patterns.
using awk
awk 'nr==fnr&&nf{a[++x]=$0;next} fnr==1{current=1} $0~a[current]{current<x&¤t++||success=1} end{if(success)print "success";else print "fail"}' file1 file2
Comments
Post a Comment