Script to manipulate logfile text

Hi guys, I was wandering if a Shell guru could give me some advice on tackling a problem.

I have used a mixture of grep, cut and awk to get data from a log file in the following format:

14/11/08 10:39:      Checking currenly    :  Enabled
14/11/08 10:39:      Records allocated    :  221
14/11/08 10:39:      Records Freed         :  0
14/11/08 10:39:      Records Aged          :  56

list continues in same format etc.......

What I would now like to do is pipe it into another bit of script which would leave it in a comma delimited format with date timestamp so i can throw it into a sql data base, format like so.

14/11/08 , 10:39 , Enabled , 221 , 0 , 56

I have come a little stuck and am not sure how I would do this so any advice would be much appreciated.

Just to add a quick note the formatting has slightly messed after posting to the forum, everything is in straight clear cut colums with set character positions

How do you know how far to carry the
Enabled , 221 , 0 , 56 ?

Are you grouping things with the same date/time, or until some other message comes up?

Those values are taken from the last column until the end of the file, the date time stamp is the same due to earlier text processing. thats why I just want to end up with

14/11/08 , 10:39 , Enabled , 221 , 0 , 56

Try this:

awk '{
s=$1" , "substr($2,1,5)" , "$6
for(i=1;i<4;i++) {
  getline;s=s" , "$6
}
print s}' file

Regards

Could you possibly run me through what each line of the code is doing so i can alter it if need be regards ross

And thanks works great on the text I provided above

Ok one more question how would I modify the above if the format above was as such like below.

14/11/08 10:39:  Records allocated................ 221
14/11/08 10:39:  Records Freed.................... 0
14/11/08 10:39:  Records Aged..................... 20
14/11/08 10:39:  Records allocated................ 221
14/11/08 10:39:  Records Freed.................... 0
14/11/08 10:39:  Records Aged..................... 20 

Ok, here we go:

awk '{
s=$1" , "substr($2,1,5)" , "$6
for(i=1;i<4;i++) {
  getline;s=s" , "$6
}
print s}' file
s=$1" , "substr($2,1,5)" , "$6

On the 1st, 5th, 9th line etc. assign field 1, the first 5 characters of the 2nd field and the 6th field to string s using " , " as delimiters.

for(i=1;i<4;i++) {
  getline;s=s" , "$6
}

Get the next 3 lines and add the 6th field after the string s.

print s

Print the string s and get the next line.
After printing the first string the next line is the 5th line since we have read 3 strings in the loop after the 1st string.

Regards

And what should be the output?

Regards

Same format as before

14/11/08 , 10:39 , 221 , 0 , 20 , 221 , 0 , 20

thanks for all your help

perl:

open FH,"<a.txt";
while(<FH>){
tr/\n//d;
my @temp=split(/ +/,$_);
my $str=sprintf("%s,%s",$temp[0],$temp[1]);
$hash{$str}=sprintf("%s,%s",$hash{$str},$temp[5]);
}
foreach $key (keys %hash){
print $key,$hash{$key},"\n";
}