Get MINUS data beween two files in UNIX

I have two files in Unix.

File 1 contain:

1.- Jhon
2.- Peter
3.- Marie

File 2 contain:

2.- Peter
5.- Luouis

I want to create a new file from these two file.
The result that I want is:

File 3:

1.- Jhon
3.- Marie

Basically the result is like next below:

enter image description here

But unfortunately, the result is like this:

File 3:

1.- Jhon
3.- Marie
5.- Luouis

I want the MINUS from file 1 to file 3, and not the DISTINCT between both files

The command that I’m using is:

cat file1 file2 | sort  | uniq -u  > file3

Any suggest for this?


Source: unix

Leave a Reply