1 |
On Tue, Nov 22, 2011 at 10:26, Adam Carter <adamcarter3@×××××.com> wrote: |
2 |
>>> sed -r -e 's/(.*)-[0-9].*/\1/' |
3 |
>> |
4 |
>> You know, that looks familiar... are you trying to get a package name from |
5 |
>> the list of eix-installed? :-) |
6 |
> |
7 |
> No - its non-gentoo. In this case it hasn't worked |
8 |
> |
9 |
> $ echo net-snmp-5.3.2.2-5.cp843034001.i386.rpm | sed -r -e 's/(.*)-[0-9].*/\1/' |
10 |
> net-snmp-5.3.2.2 |
11 |
> |
12 |
|
13 |
Ah, yes. sed's greedy regex again messes up the plan >.< |
14 |
|
15 |
Here's an alternative: |
16 |
|
17 |
sed -r -e 's/-[0-9].*//' |
18 |
|
19 |
Basically, the regex above tries to (greedily) match "dash followed by |
20 |
a digit followed by zero or more (any) characters"... then deletes the |
21 |
match. Thus leaving the front part of the string untouched. |
22 |
|
23 |
(And yes, this time I've tested the sed incantation) |
24 |
|
25 |
Rgds, |
26 |
-- |
27 |
FdS Pandu E Poluan |
28 |
~ IT Optimizer ~ |
29 |
|
30 |
• LOPSA Member #15248 |
31 |
• Blog : http://pepoluan.tumblr.com |
32 |
• Linked-In : http://id.linkedin.com/in/pepoluan |