Katewadi
asked on
Need a shell script (ksh) that uses an Awk array to process an input file
Hello Experts,
I am looking for a shell script (preferabally KSH) which processes a large input file (a log file) and provides an output file in a certain format. I want to use an Awk array to process each line of the input file and print the required output feilds to a file.
I need an array, because there are various WebContainer Types and they have different Broker transactions within them.
Thanks,
-Katewadi
########################## ##########
Sample Input file data:
2012-03-15 05:50:09,916 [WebContainer : 2] INFO BPServlet (AddUpdateProgramGroup) - ------------------- basicPerform starting command <AddUpdateProgramGroup> -------------------
05:50:10,043 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction started
2012-03-15 05:50:10,215 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction completed in 165 milliseconds : EXSIDMOD/MFPR/NOTIFY
2012-03-15 05:50:10,219 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction started
2012-03-15 05:50:10,390 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction completed in 168 milliseconds : EXSIDMOD/MFPR/NOTIFY
2012-03-15 05:50:10,392 [WebContainer : 2] INFO BPServlet (AddUpdateProgramGroup) - ------------------- basicPerform command <AddUpdateProgramGroup> done in 476 milliseconds -------------------
########################## ########
Format of the Output File:
Date|Start-Time|WebContain er-Number| Type|End-T ime|Broker -Time|Tota l-Transact ion-Time
2012-03-15|05:50:09,916|2| AddUpdateP rogramGrou p|05:50:10 ,392|333|4 76
I am looking for a shell script (preferabally KSH) which processes a large input file (a log file) and provides an output file in a certain format. I want to use an Awk array to process each line of the input file and print the required output feilds to a file.
I need an array, because there are various WebContainer Types and they have different Broker transactions within them.
Thanks,
-Katewadi
##########################
Sample Input file data:
2012-03-15 05:50:09,916 [WebContainer : 2] INFO BPServlet (AddUpdateProgramGroup) - ------------------- basicPerform starting command <AddUpdateProgramGroup> -------------------
05:50:10,043 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction started
2012-03-15 05:50:10,215 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction completed in 165 milliseconds : EXSIDMOD/MFPR/NOTIFY
2012-03-15 05:50:10,219 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction started
2012-03-15 05:50:10,390 [WebContainer : 2] INFO IDMODTransaction (AddUpdateProgramGroup) - ####### Broker Transaction completed in 168 milliseconds : EXSIDMOD/MFPR/NOTIFY
2012-03-15 05:50:10,392 [WebContainer : 2] INFO BPServlet (AddUpdateProgramGroup) - ------------------- basicPerform command <AddUpdateProgramGroup> done in 476 milliseconds -------------------
##########################
Format of the Output File:
Date|Start-Time|WebContain
2012-03-15|05:50:09,916|2|
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your input...
BTW, I tried the awk command (as-is), and apparently it did not work for me.
It gave me an output like this:
ontainer|:|C|-------------
Am I doing anything wrong? Most of the output feilds do not look as expected -- including the first and last feilds.
Could you help any furhter?
-Katewadi