I've been collecting log files from a program I'm using and 90% of the time I can correctly parse the log with my current script. Unfortunetly I can find no rhyme or reason to the header file they use for the log file, it is never exactly the same characters, bits or end in the same character. The data I want is alwasy in the following form:
Now the problem I am having is that sometimes the header has a comma "," in it and the cut command will keep that line of the header. I've only experienced one line having this problem at the top of the file but would like to check all lines for this common format and remove the lines that do not follow this format. I am new at bash scripting and can not figure out how to do this.
NOTE: the 12th comma deliminated info could contain a comma in it which is also another problem I can't figure out. If there is a comma in the 12th spot it could give me 13,14,15,ect fields if I use the cut command. Is there a way to have the last field just include everything after the last comma or does it already do that? The cut command I've been using is:
cut -f "1 2 3 4 5 6 7 8 9 10 11 12" -d , -s < file.log
Thanks for any help.