I am using SUN SOLARIS (SunOS sun4v sparc SUNW, T5240).
I have a huge data file with header and trailer. This file gets used into an ETL process. ETL skips the header record (which is the first record of the file) and loads the rest of the record. The file can be delimited (comma, tab, pipe) or fixed width.
I am trying to write a script that:
Sorts the records by first field. The value of first field is �Q� or �E�. So all �Q�record should sort first then �E� records.
After the sort above is complete, I want to split the file on every 30,000 records with rules below:
A. The first record in every split file is a header record or blank record- starting with "H"
B. The split file needs to have same name as master file with __(double underscore) and the number.
For e.g:
Master File name is: MasterFile-HP-import-20151006.txt
Split file name needs to be : MasterFile-HP-import-20151006__1.txt ; MasterFile-HP-import-20151006__2.txt and so on.
Thank you Don and RudiC for your help/advice. Appreciate your time.
I was able to run both the code suggested by RudiC using nawk and /usr/xpg4/bin/awk .
The split is working fine. But getting one small issue.The files are getting generated fine from 1 to 10. But after 10 the number starts appending to itself. Please see below: