fastest way to test file for string?

kj no.email at please.post
Fri Jun 5 07:50:50 EDT 2009



Hi.  I need to implement, within a Python script, the same
functionality as that of Unix's

   grep -rl some_string some_directory

I.e. find all the files under some_directory that contain the string
"some_string".

I imagine that I can always resort to the shell for this, but is
there an efficient way of doing it within Python?

(BTW, portability is not high on my list here; this will run on a
Unix system, and non-portable Unix-specific solutions are fine with
me.)

TIA!
-- 



More information about the Python-list mailing list