GIF89a;
:: # - is only about 2.5 times as slow as egrep (though I couldn't run # Tom's test -- this system, a vanilla SGI, only has /etc/terminfo) import string import sys import re def main(): pats = map(chomp, sys.stdin.readlines()) bigpat = '(' + '|'.join(pats) + ')' prog = re.compile(bigpat) for file in sys.argv[1:]: try: fp = open(file, 'r') except IOError, msg: print "%s: %s" % (file, msg) continue lineno = 0 while 1: line = fp.readline() if not line: break lineno = lineno + 1 if prog.search(line): print "%s:%s:%s" % (file, lineno, line), def chomp(s): return s.rstrip('\n') if __name__ == '__main__': main()