I'd like to count the instances of 'text' after each 'header'. I'm using grep and awk but open to any tools. My file looks like this:
header1
text1
text2
text3
header2
text1
header3
header4
text1
text2
...
A great output would look like this
header1 3
header2 2
header3 0
header4 2
...
My question is similar to this, but requires not counting the total occurrences and instead the occurrences between a certain string.