Hi All,
Can anyone please assist me with my awk statement.
I am trying to search for a pattern in $7 field and if true print ,read next line and if the next line starts with +++= print, read the next line and if next line starts with +++= print and if not, return back to the search criteria and so on.
awk '{if($7~/0152670293/){
print
if (!(getline > 0)) exit
while (NF > 1 && $1 = "+++=") {
print
if (!(getline > 0))exit
}
}
}' file
By running the above scripts my output
DSB=fb 00 80 00 04 0a 015267029300 0000 0000 040907141839 0a 013799194700000000
+++= 0000001000290000004620090101ac02c000ad043f003d00064a4744484142f9
+++= 00aa03041023ab08454e5155495259201704d907cc1fe007462000000005000a
+++= 0000001000290000004620090101ac02c000ad043f003d00064a4744484142f9
+++= 00aa03041023ab08454e5155495259201704d907cc1fe007462000000005000a
etc
Input File
DSB=fb 00 80 00 01 0a 011883633600 0000 0000 04090714192b 0a 012314891100000000
+++= 0000001000110000007f20000101ac024000ad042d002c00064a47444841428e
+++= 03aa03041023ab08454e515549523220170239087f200000000000000035000e
DSB=fb 00 80 00 04 0a 015267029300 0000 0000 040907141839 0a 013799194700000000
+++= 0000001000290000004620090101ac02c000ad043f003d00064a4744484142f9
+++= 00aa03041023ab08454e5155495259201704d907cc1fe007462000000005000a
DSB=fb 00 90 00 04 0a 027213491800 0000 0000 04090714192b 00 000000000000000000
+++= 3000000001020000002218090101064a4744484142a703aa03041023ab08454e
+++= 5155495259200084f100f27cf100f28801a0bc50009f7900009f790100000000
DSB=fb 00 80 00 04 0a 043743718300 0000 5600 04090714192c 0a 043726332600000000
+++= 210000000035000000581a090102130553555a414e03094d414b484142414e45
+++= 064a
+++= 474448414200060b504c5a4841427600aa03041025ab0844454d414e44202000c8d893000000000080e71c13a0be3a0000016800000005f680e9b04351d3
DSB=fb 00 80 00 01 0a 039978312700 0000 0000 04090714192d 0a 021671859400000000
+++= 0000001000400000006920000101ac024000ad0414001400064a474448414225
+++= 06aa03041023ab08454e51554952592017027f17692000000000000000000000
Many Thanks
Chris
Can anyone please assist me with my awk statement.
I am trying to search for a pattern in $7 field and if true print ,read next line and if the next line starts with +++= print, read the next line and if next line starts with +++= print and if not, return back to the search criteria and so on.
awk '{if($7~/0152670293/){
if (!(getline > 0)) exit
while (NF > 1 && $1 = "+++=") {
if (!(getline > 0))exit
}
}
}' file
By running the above scripts my output
DSB=fb 00 80 00 04 0a 015267029300 0000 0000 040907141839 0a 013799194700000000
+++= 0000001000290000004620090101ac02c000ad043f003d00064a4744484142f9
+++= 00aa03041023ab08454e5155495259201704d907cc1fe007462000000005000a
+++= 0000001000290000004620090101ac02c000ad043f003d00064a4744484142f9
+++= 00aa03041023ab08454e5155495259201704d907cc1fe007462000000005000a
etc
Input File
DSB=fb 00 80 00 01 0a 011883633600 0000 0000 04090714192b 0a 012314891100000000
+++= 0000001000110000007f20000101ac024000ad042d002c00064a47444841428e
+++= 03aa03041023ab08454e515549523220170239087f200000000000000035000e
DSB=fb 00 80 00 04 0a 015267029300 0000 0000 040907141839 0a 013799194700000000
+++= 0000001000290000004620090101ac02c000ad043f003d00064a4744484142f9
+++= 00aa03041023ab08454e5155495259201704d907cc1fe007462000000005000a
DSB=fb 00 90 00 04 0a 027213491800 0000 0000 04090714192b 00 000000000000000000
+++= 3000000001020000002218090101064a4744484142a703aa03041023ab08454e
+++= 5155495259200084f100f27cf100f28801a0bc50009f7900009f790100000000
DSB=fb 00 80 00 04 0a 043743718300 0000 5600 04090714192c 0a 043726332600000000
+++= 210000000035000000581a090102130553555a414e03094d414b484142414e45
+++= 064a
+++= 474448414200060b504c5a4841427600aa03041025ab0844454d414e44202000c8d893000000000080e71c13a0be3a0000016800000005f680e9b04351d3
DSB=fb 00 80 00 01 0a 039978312700 0000 0000 04090714192d 0a 021671859400000000
+++= 0000001000400000006920000101ac024000ad0414001400064a474448414225
+++= 06aa03041023ab08454e51554952592017027f17692000000000000000000000
Many Thanks
Chris