Print lines between two repetitive patterns

Hi users

I have one file which has number of occurrence of one pattern

examples

Adjustmenttype,11
xyz 10
dwe 9
abd 13
def 14
Adjustmenttype,11
xyz 24
dwe 34
abd 35
def 11
nmb 12
Adjustmenttype, not eleven
....
...
...
Adjustmenttype,11
...
..
..
Adjustmenttype,11

i want to print the lines between the two occurrence of Adjustmenttype,11 into separate file

Adjustmenttype,11
---
---
--

Adjustmenttype,11
--
--
--

hope my query is clear

can anyone help me with

i tried with sed command... but may be i am doing it wrong way

Thanks in advance

BR//

Hi,

Not sure the format of your output. Do you want the word 'Adjustmenttype,11'? Only the first one? With one blank line between them? Try this 'sed' command and tell:

$ sed -n '/Adjustmenttype,11/,/Adjustmenttype,11/ { H ; x ; /.\+\nAdjustmenttype,11/ { s/.*// ; x ; s/.*// ; x }; x ; p }' infile > outfile

Regards,
Birei

awk  '/Adjustmenttype,11/ && i==0{p=1;i=NR;x++}/Adjustmenttype,11/ && NR>i {p=0;i=0}p==1{print $0>x".txt"}'

this code would generate two files named 1.txt 2.txt

 
cat 1.txt
Adjustmenttype,11
xyz 10
dwe 9
abd 13
def 14

 
cat 2.txt
Adjustmenttype,11
...
..
...
..
..

is this what you want?