I have a task I need to do daily on a RedHat Linux box, which is:
Compare two files which are in the format:
etc.
Each row is a record. You can't get duplicate records in either file, but you can have records that match across the 2 files. fielda is the primary field, i.e. uniquely identifies each record. However, with each day, some details may change. Specifically:
1. fields b-e corresponding to fielda, may change.
2. there may be a record with a fielda which has not yet been encountered.
e.g.
File1:
one,apple,tony,cat
two,orange,sarah,dog
four,apple,jack,dog
File2:
one,apple,tony,dog
two,orange,sarah,dog
three,lemon,tom,horse
In File2 the first record changes, the second record is the same, the third record is new.
In reality, File1 will be a 'master' file, and File2 will be a daily log which I'll compare to File1. If there are identical records, I'll ignore them. If there are new records in File2, I'll add them to File1. If there are differences between a record in File1 and a record in File2 which have the same fielda, then I want the records removed from both file and input into File3.temp which I will (for now) manually deal with.
So to continue the example, now:
File1:
two,orange,sarah,dog
four,apple,jack,dog
three,lemon,tom,horse
File3.temp:
one,apple,tony,dog
one,apple,tony,cat
I hope this is clear. Thanks for your help!!!!
Mark.
Compare two files which are in the format:
Code:
fielda,fieldb,fieldc,fieldd,fielde
fielda,fieldb,fieldc,fieldd,fielde
fielda,fieldb,fieldc,fieldd,fielde
etc.
Each row is a record. You can't get duplicate records in either file, but you can have records that match across the 2 files. fielda is the primary field, i.e. uniquely identifies each record. However, with each day, some details may change. Specifically:
1. fields b-e corresponding to fielda, may change.
2. there may be a record with a fielda which has not yet been encountered.
e.g.
File1:
one,apple,tony,cat
two,orange,sarah,dog
four,apple,jack,dog
File2:
one,apple,tony,dog
two,orange,sarah,dog
three,lemon,tom,horse
In File2 the first record changes, the second record is the same, the third record is new.
In reality, File1 will be a 'master' file, and File2 will be a daily log which I'll compare to File1. If there are identical records, I'll ignore them. If there are new records in File2, I'll add them to File1. If there are differences between a record in File1 and a record in File2 which have the same fielda, then I want the records removed from both file and input into File3.temp which I will (for now) manually deal with.
So to continue the example, now:
File1:
two,orange,sarah,dog
four,apple,jack,dog
three,lemon,tom,horse
File3.temp:
one,apple,tony,dog
one,apple,tony,cat
I hope this is clear. Thanks for your help!!!!
Mark.