Re: grep regular expression for this



sinbad wrote:
grep should match a string like abc and should match whatever word
that follows it, and display
only these two matching words.

for example
-----------
abc
abc xyz
abcd
some text abc def

In the above file grep should match only lines 2 and 4 and give output

abc xyz
abc def

what can be the possible regular expressions

$ echo "abc
abc xyz
abcd
some text abc def" | egrep -o 'abc +[[:alpha:]]+'
abc xyz
abc def



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.