Well, I guess "it all depends." If you do something like this all the time, then this is yet another demonstration of just how powerful
awk can be. If it's a one-time task then obviously it's overkill; do it with an editor and be done. But I suspect that this isn't a one-time task.
In the example listed below, by the way, I suspect that
FS ("field separator") should have been used versus
OFS ("
output-field separator"). But the strategy used is:
- At the beginning of the file (BEGIN rule), set the record-separator to "nothing" and the field separator to "two adjacent newlines." Thus, awk will see the paragraphs as "fields."
- For each record (no rule), stack up the paragraphs in an array.
- At the end of the file (END rule), output (only) the first two paragraphs. (Arrays in awk are associative, so the subscripts, "[1]" and "[2]", are correct.)