[ Date Index ]
[ Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
Re: [LUG] grep/sed print matching group only
- To: list@xxxxxxxxxxxxx
- Subject: Re: [LUG] grep/sed print matching group only
- From: Philip Hudson <phil.hudson@xxxxxxxxx>
- Date: Tue, 28 Dec 2010 17:37:30 +0000
- Delivered-to: dclug@xxxxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=K8+yB+w1f4i1cetujaHTsfg0a6D45T9e6mMkzTYQDTw=; b=us4/SrwLNit9ZfdK8QJZH7/s4EnNPQ/ySZ/M1YcEGNiJB0uMR6B0+Umx2JZkYTW/VL bJSU9Jo4U5AbIOcl8/8mst896KSaW8wKMMRBj6+6QnSbSgKdK/buXaVB4yXZh8zv86l7 1uzfvhkAMZsTFClQgCwT9/5mUFyaNhksuhvSw=
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