#!/usr/bin/python import os import sys if __name__ == "__main__": if len(sys.argv) < 4: print "Use: %s FILE1 FILE2 DEST_FILE" % sys.argv[0] exit(1) file1 = sys.argv[1] file2 = sys.argv[2] dest = sys.argv[3] lines = lines_cmp = [] notfound = [] with open(file1, 'r') as ff: lines = ff.readlines() with open(file2, 'r') as ff2: lines_cmp = ff2.read() for line in lines: if not line in lines_cmp: notfound.append(line) with open(dest, 'w') as f: f.write('\n'.join(notfound))