Posted by: gidilat August 18, 2009
--Comparing Text Strings--
Login in to Rate this Post:     0       ?        
Create two text files.
x.txt with
abc
def
def
ghi

and y.txt with
bcd
def
ijk
jkl

Issue following commands (at cygwin prompt)
//sort and copy unique elements of x to x1
sort -u x.txt > x1.txt
//sort and copy unique elements of y to y1
sort -u y.txt > y1.txt

//copy lines that appear in the both x1 and y1 to z
comm -1 -2 x1.txt y1.txt >z.txt

//output lines that appear in x1 only
comm -2 -3 x1.txt z.txt

//output lines that appear in y1 only
comm -2 -3 y1.txt z.txt

Works for this limited dataset.
Give it a try.



Read Full Discussion Thread for this article