Adapted from a grep in python.
Accepts a list of filenames via [2:]
, does no exception handling:
#!/usr/bin/env python
import re, sys, os
for f in filter(os.path.isfile, sys.argv[2:]):
for line in open(f).readlines():
if re.match(sys.argv[1], line):
print line
sys.argv[1]
resp sys.argv[2:]
works, if you run it as an standalone executable, meaning
chmod +x
first