Merge 2 files

Hello,

i'd like a bash script to merge 2 files without duplicate lines.
Example :

file1 :

toto
titi

file2 :

toto
tata

Expected result, file3 :

toto
titi
tata

Thank's.

Did you search this site for a solution? Anyway:

cat file1 file2 |sort -r |uniq >file3

Something like this:

$ cat test1.txt
toto
titi
$ cat test2.txt
toto
tata
$ perl -nle 'print if ! $seen{$_}++;' test1.txt test2.txt
toto
titi
tata

If you are not too much worried about the order then,

sort -u f1 f2
tata
titi
toto
cat f1 f2 | sort -u > f3 

But it wont be in the order as you expect. Is this okay with you?

It's ok.

Thank's !