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:41:24
Message-Id: 4ECB196C.6060803@uh.edu
In Reply to: [gentoo-user] sed/awk question by Adam Carter
1 I'd use sed and the regex "-[0-9]" to delimit the field
2
3
4 foo=`echo '123--bad-2xyz-3--' | sed -r -e "s/-[0-9].*//"`
5 echo $foo
6 123--bad
7
8
9 Helpful?
10
11 Adam Carter wrote:
12 > Hi All,
13 >
14 > I need to cut a string, which happens to be a filename, using the
15 > first dash that's followed by a numeral, so cut -f 1 -d"-" fails if
16 > the filename has an extra dash. How do i do this?
17 >
18 >
19
20 --
21 University of Houston, Cougar Card services support.

Replies

Subject Author
Re: [gentoo-user] sed/awk question Joseph Davis <joseph@××.edu>
Re: [gentoo-user] sed/awk question Adam Carter <adamcarter3@×××××.com>