#!/usr/bin/env python """ mutexdiff Kelvie Wong Compares two files and prints lines that are not exclusive to a particular file. This behavior may be inversed using the `-i' command line parameter. """ import sys, os inverse = False for arg in sys.argv: if arg[0] == "-": if arg[1] == "i": # Invert it inverse = True sys.argv.remove("-i") # sys.argv is the argument list, argv[1] is the first argument, # argv[2] is the second, and so on file1 = open(sys.argv[1]) file2 = open(sys.argv[2]) items = [] for line in file2: items += [line] for line in file1: if not inverse: if line not in items: print line.strip("\n") else: if line in items: print line.strip("\n")