[Splitting file] Extracting group of segments from one file to others

Hi there,

I need to split one huge file into separate files if the condition is fulfilled according to that the position between 97 and 98 matches with �IT� at the segment MAS. There is no delimiter file is fix-width with varous line length.

Could you please help me how I do split the file into separate files like <filename>.[0-9][0-9][0-9].IT

BTW I meant as multiple segment messages in one file is something like that

MAS		NZ	-len 200-	(1st msg)
DOS 			-len 175-
TMP			-len 66-
CON			-len 388-
...
...
MAS		IT			(2nd msg)
DOS 
TMP
PTY
...
...
MAS		IN			(3rd msg)
DOS 
TMP
GDS
...
...

...
...
MAS		IT			(nth msg)
DOS 
TMP
...
...

According to the scenario, I have to create two new files for msg 2 and n and they will be kept in <filename>.001.IT and <filename>.00m.IT -m is the file count-
And file <filename>.001.IT looks like

MAS		IT			
DOS 
TMP
PTY
...
...

Thanks in advance,

Ciao

Sounds like a job for csplit.