Anis_Stack
Anis_Stack

Reputation: 3452

check duplicated email and remove it from file

I have two files, email_liste1.txt ; email_liste2.txt. I would like to remove all email which exist in email_liste2 file from email_liste1 file.

finally I want to have email_liste1 without email address which exist in email_liste2.

email_liste1 and email_liste2 contain only email address

example :

email_list1 : {[email protected] ; [email protected] ; [email protected] ; [email protected] ; [email protected] ;[email protected] ; etc ...}.

email_list1: { [email protected] ; [email protected] ; [email protected] ; etc ...}

so, there is any way to do that with Linux command ? thank

Upvotes: 0

Views: 205

Answers (1)

Use grep's "-v" flag to invert the match.

$ cat file1
[email protected]
[email protected]
[email protected]
[email protected]

$ cat file2
[email protected]
[email protected]

$ grep -v -f file2 file1
[email protected]
[email protected]

$ grep -v -f file2 file1 > new-file

$ cat new-file
[email protected]
[email protected]

Upvotes: 1

Related Questions