Gentoo Archives: gentoo-user

From: Joseph Davis <joseph@××.edu>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] sed/awk question
Date: Tue, 22 Nov 2011 03:49:04
Message-Id: 4ECB1B39.2030605@uh.edu
In Reply to: Re: [gentoo-user] sed/awk question by Joseph Davis
1 Oh, and you can get the other end next by
2
3
4 foo2=`echo '123--bad-2xyz-3--' | sed -r -e "s/$foo//"`
5 echo $foo2
6 -2xyz-3--
7
8 Joseph Davis wrote:
9 > I'd use sed and the regex "-[0-9]" to delimit the field
10 >
11 >
12 > foo=`echo '123--bad-2xyz-3--' | sed -r -e "s/-[0-9].*//"`
13 > echo $foo
14 > 123--bad
15 >
16 >
17 > Helpful?
18 >
19 > Adam Carter wrote:
20 >> Hi All,
21 >>
22 >> I need to cut a string, which happens to be a filename, using the
23 >> first dash that's followed by a numeral, so cut -f 1 -d"-" fails if
24 >> the filename has an extra dash. How do i do this?
25 >>
26 >>
27 >
28
29 --
30 University of Houston, Cougar Card services support.