How can i prepare a file by comparing two other files?

File 1 data:

TestA
TestB
TestC

File 2 data:

TestA
TestD
TestE

My Output File (pick all from both and create a file without duplicate data)
----------------------------------------------------------------------

TestA
TestB
TestC
TestD
TestE

----------------------------------------------------------------
here, TestA comes in both files, i dont want to duplicate it (appear multiple times) in my output file. How can i do it?

Thanks in advance,

-mac

awk '!x[$0]++' file1 file2

I've misunderstood the request. The previous script removes duplicate entries but doesn't sort the data.

You can simply use:

sort -u file1 file2

Hi,

Follow one should be ok for you.

sort file1 > t1
sort file2 > t2
comm t1 t2 | sed 's/	//g'
rm t1 t2