Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.

Cat test

Nov 10, 2012 5:17:53 AM 
INFO: Request Type
Line 1. <fullOperation>MAKE:NUMBER:9366109380:PPAY2;</fullOperation>
Line 2. <starttime>20081003000047</starttime>
Line 3. <stoptime>20081003000047</stoptime>
Line 4. <fullResult>940120105;;</fullResult>
Line 5. <status>FAILED</status>
Nov 10, 2012 5:20:53 AM
WARNING: Request Method
Line 1. <fullOperation>MAKE:NUMBER:5424683284:PPAY2;</fullOperation>
Line 2. <starttime>20081003000047</starttime>
Line 3. <stoptime>20081003000047</stoptime>
Line 4. <fullResult>940120105;;</fullResult>
Line 5. <status>FAILED</status>
Nov 10, 2012 5:25:53 AM
FATAL: Response Type
Line 1. <fullOperation>MAKE:NUMBER:5424678435:PPAY2;</fullOperation>
Line 2. <starttime>20081003000047</starttime>
Line 3. <stoptime>20081003000047</stoptime>
Line 4. <fullResult>940120105;;</fullResult>
Line 5. <status>FAILED</status>

Result
---------

Nov 10, 2012 5:17:53 AM,INFO,Request Type,MAKE:NUMBER:9366109380:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED
Nov 10, 2012 5:20:53 AM,WARNING,Request Method,MAKE:NUMBER:5424683284:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED
Nov 10, 2012 5:25:53 AM,FATAL,Response Type,MAKE:NUMBER:5424678435:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED

any help will be much appreciated.

many thanks
laknar

awk -F'[<|>]' ' {
 if($0 ~ /Line/)
   printf "%s,", $3;
 if($0 ~ /^Nov/)
   printf "\n%s,", $0;
 if($0 ~ /(Request|Response)/)
  printf "%s,", $0;
} END { printf "\n"; } ' infile

Nov 10, 2012 5:17:53 AM,INFO: Request Type,MAKE:NUMBER:9366109380:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED,
Nov 10, 2012 5:20:53 AM,WARNING: Request Method,MAKE:NUMBER:5424683284:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED,
Nov 10, 2012 5:25:53 AM,FATAL: Response Type,MAKE:NUMBER:5424678435:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED,

Hi bipinajith, Thank you so much for your quick response.

Can you please explain this script . Actually the date part could be any month not only "Nov" month. And for each search string i need to read the previous record to capture the date, After search string there could be some records without having HTML tags. In this scenario will this script work?.

Thanks again. i will test this script.

Regards,
Laknar

Date part check you can replace with (string ending with AM or PM):-

if($0 ~ /(PM$|AM$)/)

For Lines without tags, this script will fail.

The script provided by bipinajith works well. But there could be many date above each request type in which i need to pick the date immediately before the Request type string. i have highlighted the dates in bold. we cannot seach with date and time since it will be changed month on month. Could you please suggest me to get this date?.

Cat test


Nov 10, 2012 5:12:53 AM 
Nov 10, 2012 5:13:53 AM 
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1. <fullOperation>MAKE:NUMBER:9366109380:PPAY2;</fullOperation>
Line 2. <starttime>20081003000047</starttime>
Line 3. <stoptime>20081003000047</stoptime>
Line 4. <fullResult>940120105;;</fullResult>
Line 5. <status>FAILED</status>
Nov 10, 2012 5:18:53 AM 
Nov 10, 2012 5:19:53 AM 
Nov 10, 2012 5:20:53 AM
WARNING: Request Method
Line 1. <fullOperation>MAKE:NUMBER:5424683284:PPAY2;</fullOperation>
Line 2. <starttime>20081003000047</starttime>
Line 3. <stoptime>20081003000047</stoptime>
Line 4. <fullResult>940120105;;</fullResult>
Line 5. <status>FAILED</status>
Nov 10, 2012 5:22:53 AM 
Nov 10, 2012 5:23:53 AM
Nov 10, 2012 5:25:53 AM
FATAL: Response Type
Line 1. <fullOperation>MAKE:NUMBER:5424678435:PPAY2;</fullOperation>
Line 2. <starttime>20081003000047</starttime>
Line 3. <stoptime>20081003000047</stoptime>
Line 4. <fullResult>940120105;;</fullResult>
Line 5. <status>FAILED</status>

Result
---------

Nov 10, 2012 5:17:53 AM,INFO,Request Type,MAKE:NUMBER:9366109380:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED
Nov 10, 2012 5:20:53 AM,WARNING,Request Method,MAKE:NUMBER:5424683284:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED
Nov 10, 2012 5:25:53 AM,FATAL,Response Type,MAKE:NUMBER:5424678435:PPAY2;,20081003000047,20081003000047,940120105;;,FAILED
awk -F'[<|>]' ' {
 if($0 ~ /(PM|AM)/) {
  dt=$0;
  getline;
  if($0 ~ /(Request|Response)/) {
   rt=$0; getline; fo=$3; getline; srt=$3; getline; spt=$3; getline; fr=$3; getline; st=$3;
   printf "%s,%s,%s,%s,%s,%s,%s\n", dt, rt, fo, srt, spt, fr, st;
  }
 }
} ' test