Find distinct values

Hi,

I have two files of the following format

file1

chr1:345-456
chr2:123-456
chr2:455-678
chr3:456-789
chr3:444-555

file2

chr1:345-456
chr2:123-456
chr3:456-789

output

chr2:455-678
chr3:444-555

This is just a sample data. My file 1 has 97K records and my file 2 has 77K records.

I tried

join -v1 -v2 file1 file2

This one is giving me around 85K records. I think it is printing the common ones too.

Any thoughts on getting the above said output would be highly appreciate.

Thanks in advance.

join is for joining file if you want to find uniq line you can use� wait a minute� uniq !

sort file1 file2 | uniq -u

this code doesn't work if :

file1:
a
a
b
c
file2:
b
c
d
d
e
output:
e

if you want "a" and "d" in the output :

{sort -u file1 ;sort -u file2} | sort | uniq -u
output:
a
d
e
1 Like
cat file1 file2 |sort |uniq -u

--EDIT:

Or: "another way to misuse cat".
Sorry, I posted before reading delugeag answer.
--
Bye

1 Like