Subject: Re: printing a regular expression match
To: Michael Gorsuch <michael.gorsuch@gmail.com>
From: Klaus Klein <kleink@reziprozitaet.de>
List: netbsd-users
Date: 12/08/2006 21:25:17
Michael Gorsuch wrote:

> Hey all, I'm trying to find the right Unix tool to print out a matched
> regular expression, not just a line that matches.
>
> For example,
>
> echo [1234] | egrep \(1234\)
>
> It matches the expression, but I only want to print the match, '1234'.
>
> Any ideas?  I'm sure there's a unix tool I'm not using properly  
> here...

Yet another way, depending on ones requirements:

expr [1234] : .\*\\\(1234\\\)