Hi,
I am trying to compare two fixed width files as shown below. The file is NOT sorted. The field in bold red is the key field. The comparison needs to be based of key fields and not whole record. But needs to write out the whole record in the output.
OldFile.txt:
A100135123456789 firstname mi lastname .......
A100112123456677 firstname mi lastname .......
A189135123456777 firstname mi lastname .......
NewFile.txt:
A100135123456789 firstname mi lastname .......
B122112123456666 firstname mi lastname .......
C123135123456444 firstname mi lastname .......
I need to compare the Old file and New file based on their key field in boldred (not the whole record) and generate two files: NewRec.txt and DropRec.txt. These two files will contain the whole record even though the comparison is done only on the key fields.
NewRec.txt: Key field that was not there in Old file but exists in New file. So comparing the key fields in the file above, the output should be
B122112123456666 firstname mi lastname .......
C123135123456444 firstname mi lastname .......
DropRec.txt: Key field that was there in Old file but NOT in new file. So comparing the key fields in the file above, the output should be:
A100112123456677 firstname mi lastname .......
A189135123456777 firstname mi lastname .......
The comparison is on the key field and not the whole file. The file is fixed width. The key field is from character 1 thru 22. Even though the text is only there from char 1 thru 16 and padded with spaces till 22 character.
Will really appreciate any help.
Thanks