How to compare two columns and fetch the common data with additional column

Dear All,

I am new to this forum and please ignore my little knowledge :stuck_out_tongue:

I have two types of data (a subset is given below)

data version 1:

439798   2   1       
451209   1   2       
508696   2   1       
555760   2   1 
582757   1   2       
582889   1   2       
691827   1   2       
732587   2   1   

data version 2:

439798    A/G       
451209    A/G       
451505    G/T       
451728    C/G       
451977    C/G 
465465    A/T       
468153    G/T       
468530    A/G   

So, now I want to extract common numbers from both of the datasets with AGCT given in dataversion 2

the output should be like this

439798   A/G       
451209   A/G   

Please provide me a simpler script to do so.

Thanks in advance.

regards,

Evoll

awk 'NR == FNR { 
  f[$1]
  next 
  } 
$1 in f
  ' version1 version2
1 Like

many thanks for reply and sorry for not knowing code tags.

I get the following error

awk:              ^ syntax error

[EDIT]

Thanks, it is working perfectly now. Thanks a lot for help.