The simplest way to remove lines from one file matched with lines from another file

bashbash-scriptingshell

What's the simplest way to remove lines from one file matched with lines from another file? For example, if I have the following files:

file1.csv:

u2@domain.com

file2.csv:

1,u1@domain.com,somehash1
2,u2@domain.com,somehash2
3,u3@domain.com,somehash3

As a result I'd like to have file3.csv:

1,u1@domain.com,somehash1
3,u3@domain.com,somehash3

What's the fastest way to solve this task? These files are a few GB in size.

Best Answer

grep -v -F -f file1.csv file2.csv > file3.csv seems the simplest. But you should do performance tests with smaller files first. (I agree with soandos' comment that such big files might need a dedicated solution.)

Related Question