I have a file roughly like
header_one
param1
param2
...
data_one
data1
data2
data3
data4
...
header_two
param1
param2
...
data_two
data1
data2
data3
data4
I'd like to extract all header blocks with N following lines and all data blocks with M != N following lines, keeping the order in which they appear in the file and discarding everything else.
If M == N == 8 I could e.g. do
grep -A8 -E "header_|data_"
But what if I want to have different context for each pattern?