Gentoo Archives: gentoo-user

From: Joerg.Schilling@fokus.fraunhofer.de (Joerg Schilling)
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] sed/awk question
Date: Tue, 22 Nov 2011 09:43:17
Message-Id: 4ecb6e2a.2Va21Q2V/Ue+CZXh%Joerg.Schilling@fokus.fraunhofer.de
In Reply to: Re: [gentoo-user] sed/awk question by Pandu Poluan
1 Pandu Poluan <pandu@××××××.info> wrote:
2
3 > On Tue, Nov 22, 2011 at 10:26, Adam Carter <adamcarter3@×××××.com> wrote:
4 > >>> sed -r -e 's/(.*)-[0-9].*/\1/'
5 > >>
6 > >> You know, that looks familiar... are you trying to get a package name from
7 > >> the list of eix-installed? :-)
8 > >
9 > > No - its non-gentoo. In this case it hasn't worked
10 > >
11 > > $ echo net-snmp-5.3.2.2-5.cp843034001.i386.rpm | sed -r -e 's/(.*)-[0-9].*/\1/'
12 > > net-snmp-5.3.2.2
13 > >
14 >
15 > Ah, yes. sed's greedy regex again messes up the plan >.<
16 >
17 > Here's an alternative:
18 >
19 > sed -r -e 's/-[0-9].*//'
20
21 Nust a note: sed has no option -r and 's/(.*)-[0-9].*/\1/' is a "garbled"
22 command. A corrected version would be 's/\(.*\)-[0-9].*/\1/'
23
24 So the main question is: why do you use a non-existing option?
25
26 Jörg
27
28 --
29 EMail:joerg@××××××××××××××××××××××××.de (home) Jörg Schilling D-13353 Berlin
30 js@××××××××××××.de (uni)
31 joerg.schilling@××××××××××××××××.de (work) Blog: http://schily.blogspot.com/
32 URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily

Replies

Subject Author
Re: [gentoo-user] sed/awk question Pandu Poluan <pandu@××××××.info>
Re: [gentoo-user] sed/awk question Raffaele BELARDI <raffaele.belardi@××.com>