Word-oriented GREP

Felix Lee flee at cs.psu.edu
Mon Apr 29 18:21:03 AEST 1991


>why not cut down your search space by using grep to find the lines with
>the matching patterns and then using perl, or some other unix tool to grab
>the pattern.... from the previous example you could do:
>grep V\[0-9\]\[0-9\]\[0-9\] fred.c | tr ' ' \012 | grep V\[0-9\]\[0-9\]\[0-9\]

Well, yes, you can do that if you want a word-oriented grep.

My point was, I don't want a word-oriented grep.  I don't want a
line-oriented grep either.  I want a character-oriented grep, a grep
that will just grab matching substrings from an arbitrarily stream.
And from this tool you can do word-oriented or line-oriented or
whatever-oriented grepping.

With the current line-oriented grep, you cannot search for a pattern
that spans lines.  Say you want to find occurrences of "the dog" in a
file, where the words can be separated by any whitespace, including
newlines.  You cannot do this easily with existing tools.
--
Felix Lee	flee at cs.psu.edu



More information about the Comp.unix.wizards mailing list