unterkirschner
Programmer
I am struggling to "think" like AWK but I don't seem to get it. I have a file made of blocks like these
Head;aasdad;grgsrg;asdawasd;12345;dsdad
stuff;otherstuff
stuff2;otherstuff2
stuffx;otherstuffx;
Head;asggdvxaa;estuff;otherstuff
stuff2;otherstuff2
Head;asggdvxaa;e
...and so on. I must output the blocks where there's the 12345 in the 5th field, and all the stuff UNTIL the next "Head". I tried with
/^12345/,/^Head/
But this apparently matches a single line and not a block. I'm delving in the conditional structures but I don't understand how to tell awk to "print everything until you match the NEXT "Head". I feel there must be an elegant solution but I cannot grasp it.
Thank you in advance for your insight.
Head;aasdad;grgsrg;asdawasd;12345;dsdad
stuff;otherstuff
stuff2;otherstuff2
stuffx;otherstuffx;
Head;asggdvxaa;estuff;otherstuff
stuff2;otherstuff2
Head;asggdvxaa;e
...and so on. I must output the blocks where there's the 12345 in the 5th field, and all the stuff UNTIL the next "Head". I tried with
/^12345/,/^Head/
But this apparently matches a single line and not a block. I'm delving in the conditional structures but I don't understand how to tell awk to "print everything until you match the NEXT "Head". I feel there must be an elegant solution but I cannot grasp it.
Thank you in advance for your insight.