Searching a file for multiple strings (PS)

Shawn Milochik Shawn at Milochik.com
Sat Jan 31 23:39:15 EST 2009


On Sat, Jan 31, 2009 at 3:00 PM, Tim Chase
<python.list at tim.thechases.com> wrote:
>>> I'm fairly new with python and am trying to build a fairly simple
>>> search script.  Ultimately, I'm wanting to search a directory of files
>>> for multiple user inputted keywords.  I've already written a script
>>> that can search for a single string through multiple files, now I just
>>> need to adapt it to multiple strings.
>

Not to discourage the use of Python, but it seems that fgrep with the
-f flag already does exactly what you want. If you're on Windows, you
can get the Windows version of fgrep here:
http://unxutils.sourceforge.net/

Shawn



More information about the Python-list mailing list