I am trying to filter out some data with awk. If someone could help me that would be great. Below is my input file.
Date: 10-JUN-12 12:00:00
B 0: 00 00 00 00 10 00 16 28
B 120: 00 00 00 39 53 32 86 29
Date: 10-JUN-12 12:00:10
B 0: 00 00 00 00 10 01 11 22
B 120: 00 00 00 29 23 32 16 29
Date: 10-JUN-12 12:00:20
B 0: 00 00 00 00 10 02 17 29
B 120: 00 00 35 51 42 66 14
Date: 10-JUN-12 12:00:30
B 0: 00 00 00 00 10 03 61 42
B 120: 00 00 00 44 33 52 21 52
Date: 10-JUN-12 12:00:40
B 0: 00 00 00 00 10 04 11 22
B 120: 00 00 12 87 10 01 13 42
Date: 10-JUN-12 12:00:50
B 0: 00 00 00 00 10 05 15 24
B 120: 00 00 12 87 10 01 13 42
Date: 10-JUN-12 12:01:00
B 0: 00 00 00 00 10 06 11 22
B 120: 00 00 12 87 10 01 13 42
The above input file is one block of date (i.e. field 8 of the B 0: line increments from 00 to 06 then repeats; with Date:, B 0: (except field 8 will be 10 (its 10 in the above input file) or 11) and B 120: lines changing).
So, I would like to find the B 0: line that contains 10 or 11 in field 7 and 00 in field 8 and print the line directly before it (the Date: line) and then print that B 0: line it found. Next, I would like awk to find the B 0: line that contains 10 or 11 in field 7 and 04 in field 8 and print the line directly before it (the Date: line), then print the found B 0: line, then print the line directly after the B 0: line (the B 120: line). Finally, I would like awk to find the found B 0: line that contains 10 or 11 in field 7 and 06 in field 8 and print the line directly before it (the Date: line), then print the found B 0: line, then print the line directly after the found B 0: line (the B 120: line). I would like this repeated for every block of data in the order described (again my input file in the example above only covers one blocks worth).
Ideally, I would also like the following to also occur...but if someone doesn't know how to do it..then I would be more than greatful to have the awk line needed to get the previous paragraph done. From time to time parts of data are missing. Missing data will consist always of 3 lines (Date:, B 0: and B 120: lines). So, its possible that one or more of the search lines may be missing (line B 0: with 10 or 11 in field 7 and 00 in field 8, and/or line B 0: with 10 or 11 in field 7 and 04 in field 8, and or line B 0: with 10 or 11 in field 7 and 06 in field 8). If this is the case I would like awk not to print anything and move on to the next block of data (find the next line b 0: with 10 or 11 in field 7 and 00 in field 8) and begin search and print again.
What I would like for an output file (this pattern would repeat if the input file had more than one block of data):
Date: 10-JUN-12 12:00:00
B 0: 00 00 00 00 10 00 16 28
Date: 10-JUN-12 12:00:40
B 0: 00 00 00 00 10 04 11 22
B 120: 00 00 12 87 10 01 13 42
Date: 10-JUN-12 12:01:00
B 0: 00 00 00 00 10 06 11 22
B 120: 00 00 12 87 10 01 13 42
Hopefully this isn't too confusing....I've try quite a few things and haven't had any luck.