match values in first column of two files and join the matching lines in a new file

前端 未结 2 1298
陌清茗
陌清茗 2021-01-19 04:55

I need to find matches with the string in column 1 ($1) in file1.txt with the string in column 1 ($1) in file2.txt. Then I want to join the lines where there was a match in

2条回答
  •  有刺的猬
    2021-01-19 05:35

    If you don't mind the output being ordered by the first column then you can use this invocation of the join command:

    join <(sort file1.txt) <(sort file2.txt) >out.txt
    

提交回复
热议问题