Splitting a single file to multiple files

Hi Friends ,
Please guide me with the code to extract multiple files from one file .

The File Looks like ( Suppose a file has 2 tables list ,column length may vary )

H..- > File Header....
H....- >Table 1 Header....
D....- > Table 1 Data.... 
T....- >Table 1 Trailer....
H..-> Table 2 Header..
D..-> Table 2 data..
T..->Table 2 trailer..
T..- > File Trailer 

The Output looks like : the forth field of header is the file name too

FILE1 - 

H..FILE1..- >Table 1 Header....
D....- > Table 1 Data.... 
T....- >Table 1 Trailer....

FILE2 - 
H..FILE2-> Table 2 Header..
D..-> Table 2 data..
T..->Table 2 trailer..

Welcome AspiringD,
I have a few to questions pose in response first. Your requirement isn't very clear:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.