I’d like to use a sed script like this
#n
/^TODO/,/^$/p
except that sed should stop printing the range after it comes across two consecutive blank lines, rather than just one blank line. Then it should continue scanning for the next range of interest. In other words, the end of range of interest is defined by two blank lines. I’m not even sure that an address range can handle this sort of requirement, so if there’s another way to do this, please let me know.
This should stop when it encounters two consecutive blank lines regardless of the odd/even pairing of the blank lines with non-blank lines:
Don’t print the two blank lines:
Print one of them:
Print both of them:
Edit:
And here’s how you’d make that work in your range:
Edit 2:
Per dan’s (the OP) comments and edited requirements, this seems to work to find the pattern in a range that ends in two blank lines, multiple times in a file: