1.

Solve : Determine which Multi-line missing Corresponding line?

Answer»

I have a text file which contains some type of LOG, I want to parse the file for a corresponding line, EG.,

archiving abc1
inflating abc1
some type of garbage
some type of garbage
some type of garbage
archiving abc2
inflating abc2
some type of garbage
archiving abc3
inflating abc3
some type of garbage
archiving abc4
some type of garbage
archiving abc5
inflating abc5
some type of garbage
archiving abc6
inflating abc6
some type of garbage
archiving abc7
some type of garbage
archiving abc8
inflating abc8
some type of garbage
some type of garbage

For each of the above line which has "archiving abcN", I want to know which one is missing the second half of the MESSAGE. From the above, you can see that "archving abc4" is missing "inflating abc4" line.
if you can download gawk for windows(see my sig), its a piece of cake to do

Code: [Select]C:\test>gawk "/archiving/{s=$NF;getline;if($0!~/inflating/){print \"no inflating \"s};next}" file
no inflating abc4
no inflating abc7
Thanks for posting the UNIX like utility to use. I wish I knew how to do this when I was writing some UNIX scripts awhile back, it WOULD've made life easier.



Discussion

No Comment Found