file1:
77, 4, -3, A0080
235, 5, -1, K0511
file2:
A0132, 77, -1, -2, 19.776
00000, 77, 4, -3, 18.608,
A0794, 235, -2, -2, 22.81
A0796, 235, -2, -5, 12.27
00000, 235, 5, -1, 18.992
desired output:
A0132, 77, -1, -2, 19.776
A0080, 77, 4, -3, 18.608,
A0794, 235, -2, -2, 22.81
A0796, 235, -2, -5, 12.27
K0511, 235, 5, -1, 18.992
basically to match column1, column2, column3 of file1 into column2, column3, column4 of file2, if match then replace the column1 of file2 by the value of column4 of file1.
I used:
awk 'FNR==NR {a[$1,$2,$3]++;next} a[$2,$3,$4] {print $0}' file1 file2
to get the output
00000, 77, 4, -3, 18.608,
00000, 235, 5, -1, 18.992
Then I am stuck. Please help. BTW, this is for 2 files, how's about more than 2 files in general.