[Linux-disciples] AND with grep

Stephen R Laniel steve at laniels.org
Thu May 20 16:38:21 EDT 2004


If you want to find all documents that contain both [term1]
AND [term2], not necessarily on the same line, here's my
thought on how to do it:
 
1) grep for [term1], assume that the output is of the form
'[filename]:.*$', and grab all the [filename]s that match

2) repeat 1) for [term2].

3) compare the lists obtained from 1) and 2). Return any
filenames matching both.

Is there a better way?

-- 
``We need more bunnies listening to The Connection with
  Dick Gordon and less wars in Iraq.''
 -http://shorl.com/byhapedegradra



More information about the Linux-disciples mailing list