AnotherAlan
Technical User
Hi All,
I am using AWK to parse lines of a logfile to extract pertinent data but have hit a problem that I'm not even sure I can solve with AWK.
Within the logline I have three bracketed sections; the first of which are the fixed fields. i.e There are always seven values. The second and third sections are the corresponding values to each fixed value. So in the logline example below,
First fixed value 1 has values ranging from 1.2 to 1.4 (first fields in sections two and three) and so on.
Second fixed value 2 has values ranging from 1.3 to 1.5.
Third fixed value 3 has values ranging from 1.4 to 1.6.
[1,2,3,5,10,15,20],[1.2,1.3,1.4],[1.4,1.5,1.6]
My issue is that i need to pad the second and third fields with 0.0 if no match to the fixed fields in section 1.
So, using the above, [1,2,3,5,10,15,20],[1.2,1.3,1.4,0.0,0.0,0.0,0.0],[1.4,1.5,1.6,0.0,0.0,0.0,0.0]
Clearly i'm not an expert and to be honest cannot even think of a way to do it, apart from possibly using a for loop and an associative array for section one and pumping 0.0 for any null array values.
Any help or pointers in the right direction would be most appreciated.
Regards
I am using AWK to parse lines of a logfile to extract pertinent data but have hit a problem that I'm not even sure I can solve with AWK.
Within the logline I have three bracketed sections; the first of which are the fixed fields. i.e There are always seven values. The second and third sections are the corresponding values to each fixed value. So in the logline example below,
First fixed value 1 has values ranging from 1.2 to 1.4 (first fields in sections two and three) and so on.
Second fixed value 2 has values ranging from 1.3 to 1.5.
Third fixed value 3 has values ranging from 1.4 to 1.6.
[1,2,3,5,10,15,20],[1.2,1.3,1.4],[1.4,1.5,1.6]
My issue is that i need to pad the second and third fields with 0.0 if no match to the fixed fields in section 1.
So, using the above, [1,2,3,5,10,15,20],[1.2,1.3,1.4,0.0,0.0,0.0,0.0],[1.4,1.5,1.6,0.0,0.0,0.0,0.0]
Clearly i'm not an expert and to be honest cannot even think of a way to do it, apart from possibly using a for loop and an associative array for section one and pumping 0.0 for any null array values.
Any help or pointers in the right direction would be most appreciated.
Regards