regexp to search through log files and convert into pipe delimited file?.

Can't Post

Im trying to grep a set of strings to find each record in a log file and grep the fields for the corresponding string. the scenario is to find the string and read the above line for date and also grep a field OrderID from the below lines for each search string.The search strings are "Authenticate RequestXML", "Authenticate ResponseXML", "Authorize RequestXML", "Authorize ResponseXML"

There are two possible approaches: one, if your log file is not too large, is to "slurp" the whole file into an array of lines and then process each line. The advangtage of this approach is that when you read a line with one of your key word, it is very easy to get back to the previous line to collect the date.

The other approach, which I usually prefer because I am most of the time dealing with very large files whose size may or will exceed the size of the memory available to my process, is to read the lines one at a time, but always storing the previous line, so as to be able to pick up the date of the previous line if the current line has one of the searched key word.

Adopting the second approach, you could try something like this (untested, there may be a couple of typos, but you should get the basic idea):