02-04-2009
7,
0
Join Date: Jan 2009
Last Activity: 4 February 2009, 6:47 AM EST
Posts: 7
Thanks Given: 0
Thanked 0 Times in 0 Posts
shell program code logic
Hi,
I have a file (log data) with the sample code as follows
/apps/opt | go_gen.ksh | #START | jan 28 06:15 |/home/dump
/apps/opt | go_gen.ksh | #END | jan 28 06:30 |/home/dump
/apps/opt | pend_instl.ksh | #START | jan 28 09:50 |/home/dump
/apps/opt | pend_instl.ksh | #END | jan 28 09:55 |/home/dump
/apps/opt | go_gen.ksh | #START | jan 28 11:30 |/home/dump
/apps/opt | go_gen.ksh | #END | jan 28 11:35 |/home/dump
/apps/opt | create_dump.ksh| #START | jan 28 12:51 |/home/dump
/apps/opt | create_dump.ksh| #END | jan 28 12:52|/home/dump
/apps/opt | go_gen.ksh | #START | jan 28 11:30 |/home/dump
/apps/opt | go_gen.ksh | #START | jan 28 15:30 |/home/dump
/apps/opt | go_gen.ksh | #END | jan 28 15:35 |/home/dump
/apps/opt | installed.ksh| #START | jan 28 15:56 |/home/dump
/apps/opt | installed.ksh| #END | jan 28 15:59 |/home/dump
.
.
.
(100s of logs of same format)
I need to write a shell program to create a file which contains
(1st field (file path),2nd field (file name),4th field(start time),end time (in line having #END) and 5th field(log path)..for each filename
for ex: take line1 and line2 in the sample data i mentioned..they corresponds to on file name,first line giving star time and second line giving end time.
The Problem is
1)for certain files like go_gen.ksh (highlighted as bold),there are more tha one entry in the inputlog file.I need to generate corresponding start and end times(which i am unable to get while writing in a while loop) in the new file.
2) for certain filenames like "/apps/opt | go_gen.ksh | #START | jan 28 11:30 |/home/dump" there is no corresponding ENDTIME.In such case i need to put a '-' in the endtime field in newfile.
Need to write a shell program.Please can u give me the outline and rough code.Since i am new to shell programming,i am unaware of most of the functions/commands.(even awk/sed is permisable)
Reply me as soon as possible.
Thanks in anticipation.