I have multiple blocks of awk that are printed in the following method:
awk '/<TAG>/ {print "Before"}
/<TAG>/,/<\/TAG>/ {print}
/<\/TAG>/ {print "After"}' ${LOG} > OUTPUT.txt;
AT this stage, there are the same XMLs with different data being outputted. I'd like that Output.txt will contain only the awk blocks that have a specific value within them. If this value appears once or multiple times, print the block.
Example:
Input:
<TAG>
#1
<InnerTAG something="50">Value</InnerTAG>
</TAG>
<TAG_Two>
#2
<InnerTAG something="60">Value2</InnerTAG>
</TAG_Two>
<TAG>
#2
<InnerTAG something="60">Value2</InnerTAG>
</TAG>
Print only the TAG blocks where something="60"
Output.txt:
Before
<TAG>
#2
<InnerTAG something="60">Value2</InnerTAG>
</TAG>
After
Currently, my code only prints the TAG blocks, but I'd like to "filter" it down to only the TAG blocks with something="60", or even the inner Value. essentially, by any value within the block.
How would I go about to do this?
Also, if anyone has a more detailed source to read about awk besides the following post, you'll also get an upvote and my appreciation :) Is a /start/,/end/ range expression ever useful in awk?
Cheers!