searching/grepping for words "near" each other

Michael ODonnell michael.odonnell at comcast.net
Thu Apr 30 12:24:05 EDT 2009



> I want to search a text file for a few (alphabetic) words which
> must be "near" each other, but not necessarily on the same line.

grep is pretty much "line oriented" and although it's possible to script
elaborate workarounds involving transfers back and forth between the
"pattern" space and the "hold" space it's icky and slow to work against
the grain that way.  I predict that you'll end up using something like
Python or Perl.  I thought agrep ( the "approximate grep" that's part
of Glimpse) might do the trick as it's willing to let you specify very
sloppy search terms but, alas, it too is line oriented.
 


More information about the gnhlug-discuss mailing list