Sorry, for code-historical reasons this was unnecessarily complicated. Should be:
MY_DIR = '/my/path/to/dir' FILES = os.listdir(MY_DIR) def grep(regex): output = [] for f in FILES: command = "egrep " + '"' + regex + '" ' + MY_DIR + '/' + f result = subprocess.getoutput(command) if result: output.append(result) return output -- http://mail.python.org/mailman/listinfo/python-list