FHEAD0000000001RTLG20161205110959201612055019
THEAD......
TCUST.....
TITEM....
TTEND...
TTAIL...
THEAD......
TCUST.....
TITEM....
TITEM.....
TTEND...
TTAIL...
FTAIL<number of lines in file- 10 digits;prefix 0><number of lines in file-2 - 10 digits- perfix 0> Eg: FTAIL00000006420000000640
I need to split the file into multiple files such that
Each file should have 1st record FHEAD record (fixed)
Each file should have records starting from THEAD to TTAIL
Each file should have last record FTAIL with number of lines as mentioned above <number of lines in file- 10 digits;prefix 0><number of lines in file-2 - 10 digits- perfix 0> For example: FTAIL00000006420000000640
This is a widespread problem. Ans attempts/ideas/thoughts from your side? Did you search these forums and/or look into the related threads at the bottom of this page, trying to adapt the solutions given?
What is "number of lines in file-" and "number of lines in file-2" ?
I have a few to questions pose in response first:-
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.
You could probably use csplit based on string THEAD but you would then need to insert the FHEAD record to each file you create then calculate & append the FTAIL record.
I hope that this helps, but have a try and show us where you get stuck.