Gentoo Archives: gentoo-user

From: Benjamin Lee <ben@××××××.com>
To: gentoo-user@l.g.o
Cc: Adam Carter <adamcarter3@×××××.com>
Subject: Re: [gentoo-user] sed/awk question
Date: Tue, 22 Nov 2011 04:51:44
Message-Id: 4ECB29E0.10406@b1c1l1.com
In Reply to: [gentoo-user] sed/awk question by Adam Carter
1 On 11/21/2011 06:52 PM, Adam Carter wrote:
2 > Hi All,
3 >
4 > I need to cut a string, which happens to be a filename, using the
5 > first dash that's followed by a numeral, so cut -f 1 -d"-" fails if
6 > the filename has an extra dash. How do i do this?
7
8 Here's a Bourne parameter expansion:
9
10 blee@eclipse ~ $ foo="net-snmp-5.3.2.2-5.cp843034001.i386.rpm"
11 blee@eclipse ~ $ echo ${foo%%-[0-9]*}
12 net-snmp
13
14
15 --
16 Benjamin Lee
17 http://www.b1c1l1.com/

Attachments

File name MIME type
signature.asc application/pgp-signature