Hi, I have a file like
BINDS #17:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=352 offset=0
bfp=ffffffff7d05fa48 bln=22 avl=02 flg=05
value=18
bind 1: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=24
bfp=ffffffff7d05fa60 bln=22 avl=02 flg=01
value=6
bind 2: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=48
bfp=ffffffff7d05fa78 bln=22 avl=02 flg=01
value=2
BINDS #18:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=352 offset=0
bfp=ffffffff7d05fa48 bln=22 avl=02 flg=05
value=18
BINDS #18:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=352 offset=0
bfp=ffffffff7d05fa48 bln=22 avl=02 flg=05
value=18
bind 1: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=24
bfp=ffffffff7d05fa60 bln=22 avl=02 flg=01
value=20
bind 2: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=48
bfp=ffffffff7d05fa78 bln=22 avl=02 flg=01
value=30
What I need the awk program to do is
look for BINDS =18:
and then after that if the 3 line is "value=18" , 6th line is "value=20" and 9th line is value=20 print the lines between "BINDS #18:" till "value=30"
I started to write a program as below, its not completel written and even the logic is not proper, may need help on logic as well.
The program is not working at all, compliation errors and that is on line 2. Is there something wrong on the if statement.
BEGIN
if ($1 == "BINDS #18:") {
memo = 1
LineNo = 0
}
if (memo==1) {
LineNo = LineNo + 1
}
if ( LineNo == 3 )
{
if ( $1 == "value=18" )
Keep_line = 1
}
if ( LineNo == 6 )
{
if ( $1 == "value=20" )
Keep_line = 1
}
if ( LineNo == 9 )
{
if ( $1 == "value=30" )
Keep_line = 1
}
END
And if people have better ways to solve this please do let me know....
Many thanks...
BINDS #17:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=352 offset=0
bfp=ffffffff7d05fa48 bln=22 avl=02 flg=05
value=18
bind 1: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=24
bfp=ffffffff7d05fa60 bln=22 avl=02 flg=01
value=6
bind 2: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=48
bfp=ffffffff7d05fa78 bln=22 avl=02 flg=01
value=2
BINDS #18:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=352 offset=0
bfp=ffffffff7d05fa48 bln=22 avl=02 flg=05
value=18
BINDS #18:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=352 offset=0
bfp=ffffffff7d05fa48 bln=22 avl=02 flg=05
value=18
bind 1: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=24
bfp=ffffffff7d05fa60 bln=22 avl=02 flg=01
value=20
bind 2: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=00 oacfl2=1 size=0 offset=48
bfp=ffffffff7d05fa78 bln=22 avl=02 flg=01
value=30
What I need the awk program to do is
look for BINDS =18:
and then after that if the 3 line is "value=18" , 6th line is "value=20" and 9th line is value=20 print the lines between "BINDS #18:" till "value=30"
I started to write a program as below, its not completel written and even the logic is not proper, may need help on logic as well.
The program is not working at all, compliation errors and that is on line 2. Is there something wrong on the if statement.
BEGIN
if ($1 == "BINDS #18:") {
memo = 1
LineNo = 0
}
if (memo==1) {
LineNo = LineNo + 1
}
if ( LineNo == 3 )
{
if ( $1 == "value=18" )
Keep_line = 1
}
if ( LineNo == 6 )
{
if ( $1 == "value=20" )
Keep_line = 1
}
if ( LineNo == 9 )
{
if ( $1 == "value=30" )
Keep_line = 1
}
END
And if people have better ways to solve this please do let me know....
Many thanks...