I have a text file with following content
data
void
void
void
1
2
3
end
6
7
8
9
data
void
void
void
4
5
6
end
4
5
8
9
I wanted to extract lines between strings 'data' and 'end' and have achieved it with the following awk one-liner
awk '/data/,/end/{i++} /end/{i=0} i>4' filename
The output is
1
2
3
4
5
6
Now I wanted the number of times the data point appears to be appended before each block. Something like this:
3
1
2
3
3
4
5
6
Is it possible to achieve this by awk?