How to combine 2 files and output the unique & difference?

Hi Guys,

I have two input files and I want to combine them and get the unique values and differences and put them into one file. See below desired output file.

Inputfile1:

1111111
2222222
3333333
7860068
7860069
7860071
7860072

Inputfile2:

4444444
5555555
6666666
7860068
7860069
7860071
7860072

DESIRED OUTPUT FILE:

1111111
2222222
3333333
4444444
5555555
6666666
7860068
7860069
7860071
7860072

Thanks on advance!

Br,
pinpe

Use "sort" with the "-u" (unique) option, quite straightforward:

cat /path/to/file1 /path/to/file2 | sort -u > /path/to/result

I hope this helps.

bakunin

sort -u file[1,2] > file3

:rolleyes:

1 Like

Where is Corona\d+ ? He surely would give the link to "Useless use of cat". :slight_smile:

This is more efficient command than using cat. Thanks dude! :b: :slight_smile:

Br,
pinpe