i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file
I have tried with join and awk and i keep getting blank outputs or same file
is there an easier way than what i am trying to do, with grep or seb
here is an example of the match file and the master file
so what needs to happen is if the first 2 columns of the file match then the script would pull out the entire row with the mobile number added to the match file
so basically i need the mobiles added to field 30 on the match file as all the mobiles would be in the master file
so first 2 colums of both files are surname and DOB
master file with the mobile in the 3rd
f1 f2 mobile
john 22/02/1988 7777777777
jones 19/05/1975 7888888888
etc 22/07/1990 7878787878
etc 01/01/1959 7878787878
Unfortunately, none of your $1,$2 pairs match between files 1 and 2, not even in the header. So, the result of the proposal applied to your samples is empty.
awk '
FNR == NR {h[$1,$2] = $3
next
}
{$(NF+1) = h[$1,$2]
}
1
' OFS="\t" file2 file1