[aklug] sed regex help needed

From: Lee <lee@afabco.org>
Date: Sat Nov 14 2009 - 15:09:13 AKST

heya folks,

Been working on this for a while now, and decided it's time to call for assistance.

I'm trying to use sed to extract an arbitrary length substring that begins with KB and
ends with - . That's a space-dash.

For example, given the line:

                           [43]: KB950974 - Update

I want to extract the string KB950974

and given the line:

                           [44]: KB951072-v2 - Update

I want to extract the string KB951072-v2

This is the only thing I've come close to that works:

|sed -n -e "s/.*\(KB.\{6\}\).*/\1/p"

but that's not right, because it limits the string extraction to KB and the next six
chars, with no end condition.

I suspect that the dash requirement is screwing me over since it's a reserved character.
 But I'm at a loss.

Thanks in advance!

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat Nov 14 15:09:46 2009

This archive was generated by hypermail 2.1.8 : Sat Nov 14 2009 - 15:09:46 AKST