D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] grep/sed print matching group only

 

On 28 Dec, 2010, at 4:40 pm, Simon Williams wrote:

How can I make grep or sed print a matching group *only*?

sed -n 's/^foo \(.*\) bar/\1/p' < input.txt

HTH

--
Phil Hudson                      PGP/GnuPG ID: 0x887DCA63



--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq