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(c
Hello,
I wrote the following code for using egrep on many large files:
MY_DIR = '/my/path/to/dir'
FILES = os.listdir(MY_DIR)
def grep(regex):
i = 0
l = len(FILES)
output = []
while i < l:
command = "egrep " + '"' + regex + '" ' + MY_DIR + '/' +
FILES[i]
result = s
return output
>
> Yet, I don't think that the files are searched in parallel. Am I
> right? How can I search them in parallel?
subprocess.getoutput() blocks until the command writes out all of its
output, so no, they're not going to be run in parallel. You really
shouldn'