You're replying to a comment by Gaurav Bansal.

Gaurav Bansal Permalink
February 16, 2016, 12:27

I have the following problem. There is a file that has a group of lines repeating themselves in some order. So say
AAAAA XXX YYY ZZZ
a=1
b=2
c=3
d=ACCEPT

Then
BBBBB RRR SSS TTT
a=2
b=4
c=8
d=DROP

:
:

XXXXX CCC DDD EEE
a=2
b=4
c=10
d=DROP

This continues. I want to write a script that searches for the pattern on the first line. If it finds then skips next n lines and searches for the substring DROP in the fourth line. If it finds increments a counter. I have the following script but it doesn't work correctly

/AAAA.*/ {
{{for (i=1; i<4; i++) getline var} if (match (substr(var,3,4), "DROP")) print drop; drop++;}
}

Can anyone suggest what is wrong in this?

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "unix_122": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.