I would like to grep the lines between the same occurrence of a pattern and then save each matching lines in a different file. For example, I have this:
name
aaa
bbb
bbb
ccc
name
aaa1
bbb1
ccc1
name
...
I would like to have
name
aaa
bbb
bbb
ccc
in file1
name
aaa1
bbb1
ccc1
in file 2, and so on.
I tried with a flag inversion in awk like that:
awk '/^name/ {flag=!flag; next} flag {print}'
but I'm not getting what I want.
Do you have any suggestion to do that?