I'm trying to compare two files (OLD, NEW) using their first column as the index. Each line corresponds to a record. I'd like to create a third file (FINAL) that has keeps all the records that are present on the OLD and NEW files, but at the same time updates the remaining fields in such a way that NEW replaces OLD. This is an example of what it would look like:
OLD
1001 aaaa 44
1002 bbbb 55
1003 cccc 66
1004 dddd 77
NEW
1002 bbbb 88
1003 cccc 11
1004 ffff 22
1005 hhhh 99
FINAL
1001 aaaa 44
1002 bbbb 88
1003 cccc 11
1004 ffff 22
1005 hhhh 99
Tried doing this with other tools but was not able to. Any idea of how to do this in awk?
Thanks!
wotaskd
OLD
1001 aaaa 44
1002 bbbb 55
1003 cccc 66
1004 dddd 77
NEW
1002 bbbb 88
1003 cccc 11
1004 ffff 22
1005 hhhh 99
FINAL
1001 aaaa 44
1002 bbbb 88
1003 cccc 11
1004 ffff 22
1005 hhhh 99
Tried doing this with other tools but was not able to. Any idea of how to do this in awk?
Thanks!
wotaskd