Capturing data between patterns

Hii, Friends,
I want your help in one of my problem.
My problem is as follows.

I have a flat file as follows (Just a sample)

MHT011
01(DOT)8750707asdfas8609
03(DOT)ASD3453ASD
09(DOT)876JHT87
11(DOT)sfd324ert

TTT077
01(MOB)876786klj897
06(MOB)876JHT87
07(MOB)sfd324ert
08(MOB)876JHT87
09(MOB)654rrr

ILD321
01(MKU)ASD3453ASD
01(MKU) 45HRT53
01(MKU)DFDF56723GSDF

Here I want to capture lines between MHT011 and TTT077 and want to send that data to file MHT011.rprt.
Similarly I want to capture lines between TTT077 and ILD321 and want to send that data to file TTT077.rprt

One important point to be considered is number of lines between MHT011 and TTT077 are not fixed, it can be only 1 or it can be 100.

Can you please help me resolving this problem?

Thank you in advance
Anushree.

anushree.a,

It�s not too automated, but like a first approach, yo can try this:

echo "MHT011
01(DOT)8750707asdfas8609
03(DOT)ASD3453ASD
09(DOT)876JHT87
11(DOT)sfd324ert

TTT077
01(MOB)876786klj897
06(MOB)876JHT87
07(MOB)sfd324ert
08(MOB)876JHT87
09(MOB)654rrr" | awk '/MHT011/,/TTT077/'| sed '$d' > MHT011.rprt

Dear Cgkmal,
I tried your suggestion.
However I got following error

syntax error The source line is 1.
The error context is
>>> /MHT011/,/TTT077 <<<
awk: Quitting

Please help.

Let see,

I think was a typo from me in "/TTT077/'|" a missing space.

1-) awk '/MHT011/,/TTT077/' (search between 2 patterns)

but to avoid the unneeded last line to appear is required

2-) sed '$d' (deletes last line)

Thus, taken data from file the script would be:

awk '/MHT011/,/TTT077/' inputfile | sed '$d' > MHT011.rprt
awk '/TTT077/,/ILD321/' inputfile | sed '$d' > TTT077.rprt
.
.
.
so on...

Hope it helps:b:

Wowww... its like a magic...
It worked...
Thank you sooo much...