Efficient way to map ids

后端 未结 2 1852
走了就别回头了
走了就别回头了 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

    Untested

    awk 'NR==FNR{a[$2]=$1;next}{print $0,a[$2]}' file2 file1
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题