Re:The Awk state machine parser pattern (2018)
by asicsp on Monday January 31, 2022 @04:35AM
(#30146190)
State machine of the form
awk '/start/{f=1} f; /end/{f=0}'
is commonly used to work with text bounded by unique markers. You can also use `awk '/start/,/end/'` but the state machine format can be easily adapted for more variations (like excluding either/both of the markers)
Here's a chapter from my GNU awk one-liners book with more such examples: https://learnbyexample.github.io/learn_gnuawk/processing-mul...