Process multiline input with awk
Hello, I've been trying this and I'm stuck. I've tried to search for awk multiline record processing but all the examples I've seen use a blank line as the field seperator.
Given the following input: Time: 131127 13:41:50 Query_time: 12.249749 Time: 131127 13:41:59 Query_time: 5.156203 Time: 131127 13:42:46 Query_time: 32.596008 Time: 131127 13:44:30 Query_time: 99.876977 Time: 131127 13:45:20 ... ... I want to extract fields 2 & 3 from the first line and field 2 from the second line, and repeat until EOF. Can somebody suggest an approach as I'm at a loss. Regards, |
How about using, when /Time/ print 2 & 3 and when /Query/ print just 2 :)
|
With this InFile ...
Code:
Time: 131127 13:41:50 Code:
awk '{printf $2" "$3" "; getline; print $2}' $InFile >$OutFile Code:
131127 13:41:50 12.249749 |
All times are GMT -5. The time now is 09:34 PM. |