Displaying only data matching a pattern?

Ben Scott dragonhawk at gmail.com
Mon Feb 2 11:58:23 EST 2009


On Mon, Feb 2, 2009 at 11:46 AM, Alan Johnson <alan at datdec.com> wrote:
>        -o, --only-matching
>               Print  only  the  matched  (non-empty) parts of a matching
> line, with each such part on a separate output line.

  Oh.  Hey, that's neat; I didn't know about that one.  So Kenta could
-- possibly -- do this:

	grep -o -E [[:xdigit:]]+

However, that will generate false positive matches on anything that
happens to match a hex digit and isn't within Kenta's field delimiters
(colon and backslash).  May or may not be an issue, depending on what
"foo" and "bar" really are.  And you can't use any kind of delimiter
matching without also including the delimiters in the output with
grep, can you?

-- Ben


More information about the gnhlug-discuss mailing list