Boolean searches of file content.

newsman news at youplusme.com
Sun Jan 12 01:13:19 EST 2003


> 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.

How about :
  ls | egrep 'apple' | egrep 'orange'

nm


////////////////
www.iuni.com
www.youplusme.com




More information about the Python-list mailing list