Boolean searches of file content.

Chris Young c1572young at earthlink.net
Sat Jan 11 19:46:47 EST 2003


I've just gotten Mac OS 10.2, and I'm amazed at how much search capability I
suddenly have with all the Unix BSD commands available for searching files,
etc. It's been 10 years or so since I dealt with Unix, though, and I'm
trying to figure out the best way to search for "and"
combinations of words in my files.  The "Find" window in the Finder matches
to easily -- if _any_ of the words occur.

Say I want to find only those files that have _both_ "apple" and
"orange" in them.  The command

    egrep 'apple|orange' {directory}

finds either one. Is there a way to do this with egrep? Or is something
like "perl" or "sed" better?  I want to end up with a list of files and,
if possible, the lines and line numbers where matches were found.

What would be great is some way of being able to specify how close the
words were and other details.

Thanks very much for any help.

-- Chris Young c1572young at earthlink.net



Sent using the Entourage X Test Drive.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030112/1ae87992/attachment.html>


More information about the Python-list mailing list