Search code examples
regextextcomparisondiffcomplement

How to get complementary lines from two text files?


How to get complementary lines from two text files?

File file1.txt has

123 foo
234 bar
...

File file2.txt has

123 foo
333 foobar
234 bar
...

I want to get all lines in file1.txt and not in file2.txt. The two files are hundreds of MB large and contain non-ASCII characters. What's a fast way to do this?


Solution

  • Lines, specifically?

    fgrep -vxf file2.txt file1.txt