$ marks the beginning of a record. Now because of the volume, I want to split the file into multiple files. Condition we have is:
First 'x' no. of records to 1st file, followed by 'y' no. of records to 2nd file and remaining to 3rd file
How do we logically break the file into different files so that the records (separated by '$') remain intact.
It isn't clear to me what you want to do or if the posted solution will do it.
What is the RECFM and LRECL of your input file?
You talk about a "record" starting with $ - do you mean a group of records? Do you want to move each group of records to a different file?
How does "First 'x' no. of records to 1st file, etc" relate to the groups of records? Do you really mean "first group of records, starting with $, to 1st file, etc"?
Please show an example of the records in your input file (more than one set) and what you expect for the output files. Explain the rules for getting from input to output.
In the future, please spend the time to describe what you want to do more clearly with good examples.