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
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
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
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.