Diff and intersection reporting between two text files
compare, list, python, shell
Solution
words1 = set(open("some1.txt").read().split())
words2 = set(open("some2.txt").read().split())
duplicates = words1.intersection(words2)
uniques = words1.difference(words2).union(words2.difference(words1))
print "Duplicates(%d):%s"%(len(duplicates),duplicates)
print "\nUniques(%d):%s"%(len(uniques),uniques)
something like that at least
Problem
Disclaimer: I am new to programming and scripting in general so please excuse the lack of technical terms So i have two text file data sets that contain names listed: ``` First File | Second File bob | bob mark | mark larry | bruce tom | tom ``` I would like to run a script (pref python) that outputs the intersection lines in one text file and the different lines in another text file, ex: matches.txt: ``` bob mark tom ``` differences.txt: ``` bruce ``` How would I accomplish this with Python? Or with a Unix command line, if it's easy enough?