How could I compare two files and remove similar rows in them (bash script)

前端 未结 3 1520
陌清茗
陌清茗 2021-01-28 05:21

I have two files of data with similar number of columns. I\'d like to save file2 in another file (file3) while I exclude the rows which are existed already in the file1.

<
3条回答
  •  无人及你
    2021-01-28 06:13

    grep -v -f is problematic because it searches file2 for each line in file1. With large files it will take a very long time. Try this instead:

    comm -13 <(cat file1 | tr '\t' ' ' | sort) <(sort file2)

提交回复
热议问题