Beautiful display of AWK craftsmanship. Dont miss the solutions in the comments section.
Example input file:
The standard way ..
Self-explained indented code:
The first optimization is to get rid of the print , in awk when a condition is true print is the default action , so when the flag is true the line is going to be echoed.
To delete de NEXT statement , in order o prevent printing the TAG line, we need to activate the flag after the “OUTPUT” pattern discovery and after the flag evaluation.
A slight variation of the program flow and we’re done:
PD: What if we only want to print the lines enclosed between the OUTPUT && END tags ? check this …