Code Comments
Programming Forum and web based access to our favorite programming groups.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 thanks sinbad
Post Follow-up to this messagesinbad 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
Post Follow-up to this messageIn article <ER0Ij.14196$_v3.11547@edtnps90>, "John W. Krahn" <someone@example.com> wrote: > sinbad wrote: > > $ echo "abc > abc xyz > abcd > some text abc def" | egrep -o 'abc +[[:alpha:]]+' > abc xyz > abc def I believe -o is a GNU grep extension. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE don't copy me on replies, I'll read them in the group ***
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.