awk search column from one file, if match print columns from both files

后端 未结 2 493
执笔经年
执笔经年 2021-01-05 18:59

I\'m trying to compare column 1 from file1 and column 3 from file 2, if they match then print the first column from file1 and the two first columns from file2.

here

2条回答
  •  一个人的身影
    2021-01-05 19:22

    You can use this awk:

    awk -F '[| ]+' -v OFS='\t' 'NR==FNR{a[$4]=$1 OFS $2; next}
           $1 in a{print $1, a[$1]}' file2 file1
    Cre01.g000100   chromosome_1    99034
    Cre01.g000500   chromosome_1    71569
    Cre01.g000650   chromosome_1    93952
    

提交回复
热议问题