Re: [gentoo-user] sed/awk question

2011-11-22 Thread Joerg Schilling
Pandu Poluan wrote: > >> sed -r -e 's/-[0-9].*//' > > > > Nust a note: sed has no option -r and 's/(.*)-[0-9].*/\1/' is a "garbled" > > command. A corrected version would be 's/\(.*\)-[0-9].*/\1/' > > > > So the main question is: why do you use a non-existing option? > > > > # sed --help > > Usag

Re: [gentoo-user] sed/awk question

2011-11-22 Thread Raffaele BELARDI
On 11/22/2011 10:40 AM, Joerg Schilling wrote: >> Here's an alternative: >> >> sed -r -e 's/-[0-9].*//' > > Nust a note: sed has no option -r and 's/(.*)-[0-9].*/\1/' is a "garbled" > command. A corrected version would be 's/\(.*\)-[0-9].*/\1/' > > So the main question is: why do you use a non-e

Re: [gentoo-user] sed/awk question

2011-11-22 Thread Pandu Poluan
On Tue, Nov 22, 2011 at 16:40, Joerg Schilling wrote: > Pandu Poluan wrote: > >> On Tue, Nov 22, 2011 at 10:26, Adam Carter wrote: >> >>> sed -r -e 's/(.*)-[0-9].*/\1/' >> >> >> >> You know, that looks familiar... are you trying to get a package name from >> >> the list of eix-installed? :-) >>

Re: [gentoo-user] sed/awk question

2011-11-22 Thread Joerg Schilling
Pandu Poluan wrote: > On Tue, Nov 22, 2011 at 10:26, Adam Carter wrote: > >>> sed -r -e 's/(.*)-[0-9].*/\1/' > >> > >> You know, that looks familiar... are you trying to get a package name from > >> the list of eix-installed? :-) > > > > No - its non-gentoo. In this case it hasn't worked > > > >

Re: [gentoo-user] sed/awk question

2011-11-21 Thread Pandu Poluan
On Tue, Nov 22, 2011 at 10:26, Adam Carter wrote: >>> sed -r -e 's/(.*)-[0-9].*/\1/' >> >> You know, that looks familiar... are you trying to get a package name from >> the list of eix-installed? :-) > > No - its non-gentoo. In this case it hasn't worked > > $ echo net-snmp-5.3.2.2-5.cp843034001.i

Re: [gentoo-user] sed/awk question

2011-11-21 Thread Adam Carter
> I'd use sed and the regex "-[0-9]" to delimit the field > > > foo=`echo '123--bad-2xyz-3--' | sed -r -e "s/-[0-9].*//"` > echo $foo > 123--bad > > > Helpful? Perfect - thanks!

Re: [gentoo-user] sed/awk question

2011-11-21 Thread Benjamin Lee
On 11/21/2011 06:52 PM, Adam Carter wrote: > Hi All, > > I need to cut a string, which happens to be a filename, using the > first dash that's followed by a numeral, so cut -f 1 -d"-" fails if > the filename has an extra dash. How do i do this? Here's a Bourne parameter expansion: blee@eclipse ~

Re: [gentoo-user] sed/awk question

2011-11-21 Thread Joseph Davis
Oh, and you can get the other end next by foo2=`echo '123--bad-2xyz-3--' | sed -r -e "s/$foo//"` echo $foo2 -2xyz-3-- Joseph Davis wrote: I'd use sed and the regex "-[0-9]" to delimit the field foo=`echo '123--bad-2xyz-3--' | sed -r -e "s/-[0-9].*//"` echo $foo 123--bad Helpful? Adam Cart

Re: [gentoo-user] sed/awk question

2011-11-21 Thread Joseph Davis
I'd use sed and the regex "-[0-9]" to delimit the field foo=`echo '123--bad-2xyz-3--' | sed -r -e "s/-[0-9].*//"` echo $foo 123--bad Helpful? Adam Carter wrote: Hi All, I need to cut a string, which happens to be a filename, using the first dash that's followed by a numeral, so cut -f 1 -d"

Re: [gentoo-user] sed/awk question

2011-11-21 Thread Adam Carter
>> sed -r -e 's/(.*)-[0-9].*/\1/' > > You know, that looks familiar... are you trying to get a package name from > the list of eix-installed? :-) No - its non-gentoo. In this case it hasn't worked $ echo net-snmp-5.3.2.2-5.cp843034001.i386.rpm | sed -r -e 's/(.*)-[0-9].*/\1/' net-snmp-5.3.2.2

[gentoo-user] sed/awk question

2011-11-21 Thread Adam Carter
Hi All, I need to cut a string, which happens to be a filename, using the first dash that's followed by a numeral, so cut -f 1 -d"-" fails if the filename has an extra dash. How do i do this?