[Tutor] Grepping a file for words in a list
Bob Gailer
bgailer at alum.rpi.edu
Fri Feb 24 20:27:25 CET 2006
John Purser wrote:
> Hello,
>
> I'm writing a system admin script in python that checks recently
> accessed files for keywords like "failed, denied, error,..." etc. I'm
> using popen to call grep -F <LIST> <LOG_FILE> but it's VERY slow. Can
> anyone suggest a faster method to do this?
>
I don't know whether it'd be faster, but you could read the file into a
Python string, then use re to find the keywords. What do you do after
finding them?
More information about the Tutor
mailing list