Hi Everyone,
In reference to thread thread271-1214284.
(Thanks Feherke. Used this many times.)
I'm in need of printing the lines before /match/, but instead of a constant NR, I have a constant string "Reply". I can't use a range since the block that contains /match/ appears several times, but is distinguished by a unique id that I get from the "Request" that matches "Reply". Problem is that the NR between "Reply" and /match/ is not constant. Can be 4, 5, or 6, NR before /match/.
<start of transaction <start><Request> </start><string1>text</string1><string2>match regex</string2><uniqueID>ID:123:456</uniqueID></start of transaction>
<end of transaction><end>Reply</end>{tags with text}<uniqueID>ID:123:456</uniqueID><string with regex>match</string with regex>{more tags with text}</end of transaction>
I've tried modifying Feherke's example to consistently get the lines between "Reply" and /match/, but just can't get it right. I can consistently get from match to </end of transaction>. The goal is getting the entire transaction with Request and entire Reply for /match/ and the unique id.
Thanks in advance.
Bootstrap(Robert)
In reference to thread thread271-1214284.
Code:
awk '/pattern/{for(i=0;i<19;i++)print a[(i+NR)%19];print;for(i=0;i<26;i++){getline;print}}{a[NR%19]=$0}' input.file
(Thanks Feherke. Used this many times.)
I'm in need of printing the lines before /match/, but instead of a constant NR, I have a constant string "Reply". I can't use a range since the block that contains /match/ appears several times, but is distinguished by a unique id that I get from the "Request" that matches "Reply". Problem is that the NR between "Reply" and /match/ is not constant. Can be 4, 5, or 6, NR before /match/.
<start of transaction <start><Request> </start><string1>text</string1><string2>match regex</string2><uniqueID>ID:123:456</uniqueID></start of transaction>
<end of transaction><end>Reply</end>{tags with text}<uniqueID>ID:123:456</uniqueID><string with regex>match</string with regex>{more tags with text}</end of transaction>
I've tried modifying Feherke's example to consistently get the lines between "Reply" and /match/, but just can't get it right. I can consistently get from match to </end of transaction>. The goal is getting the entire transaction with Request and entire Reply for /match/ and the unique id.
Thanks in advance.
Bootstrap(Robert)