Could some one please help to compare two files, i have used the below command but i couldnt succeed on it,
awk -F, 'NR == FNR {a[$1,$2]; next} (($1,$2) in a )' temp1.dat temp2.dat
Here is my need, need to compare first two fields in the below two dat files and merge the result as expected in file3(first field, second field, 3 field of temp1.dat, 3 field of temp2.dat)
File1:temp1.dat
A, AB,100
B,BB,200
C,CC,300
File2:temp2.dat
A,AB,10
C,CC,30
D,DF, 4
File3 :output
A, AB,100,10
C,CC,300,30
diff file1 file2
? - user529758join
command is insufficient because the criteria state that two columns must match. Of coursesed
could be used to combine the key columns first, then, after sorting each file on the new combined key column,join
would be sufficient (and a finalsed
filter could separate the joined columns again). Perhaps join would be more efficient for larger files, especially if they are already sorted on both columns. - Greg A. Woods