Efficient way to map ids

后端 未结 2 1853
走了就别回头了
走了就别回头了 2021-01-23 02:51

I have two text files,

File 1 with data like

User game count

A Rugby 2
A Football 2
B Volleyball 1
C TT 2
...

File 2



        
2条回答
  •  走了就别回头了
    2021-01-23 03:18

    Your File2 should have no records duplicated, such as no two football index records.

    awk 'FNR==NR{a[$2]=$1;next}$0=$0 FS a[$2]' file2 file1
    

提交回复
热议问题