News for hackers. Stuff that matters.
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...

Re:The Awk state machine parser pattern (2018) by marklgr on Monday January 31, 2022 @05:35AM (#30146584)
Good book, for all levels, I recall stealing several snippets into my cheatsheet.
Re:The Awk state machine parser pattern (2018) by nerdponx on Monday January 31, 2022 @09:54AM (#30148508)
I always forget that omitting the "action" after a pattern prints the line by default. Very useful tip! I'll definitely pick up a copy of this book.