help required in unix command/script

Hi All,

Please help me in writting the script
File contains:

11424444, <basicpage>
jfalfksf
<dateofbirth>10/02/2005</dateofbrith>
jkaklgja
lg'd
....
11423224444, <basicpage>
jfalfksf
<dateofbirth>11/02/2005</dateofbrith>
jkaklgja
lg'd
11433523224444, <basicpage>
jfalfksf
<dateofbirth>09/03/2005</dateofbrith>
jkaklgja
lg'd
<dateofbirth>09/03/2005</dateofbrith>

.........
.....

output in 1.txt

11424444, <basicpage>
<dateofbirth>10/02/2005</dateofbrith>

output in 2.txt

11433523224444, <basicpage>
<dateofbirth>09/03/2005</dateofbrith>
<dateofbirth>09/03/2005</dateofbrith>

Here if the dateofbrith occurence is once before the next basicpage then the output should go 1.txt file else if the dateofbrith string comes again before the next basicpage string then it should send the output to the other file say 2.txt

Thanks
Satish

Closed. Cross-post help required in writing the script