Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sed/regexp

12 views
Skip to first unread message

Hanner, Michael [SKY:P062:EXCH]

unread,
Jun 30, 2000, 3:00:00 AM6/30/00
to

Hi,

This is what I want to to:

a:\b.jar:a:\c.jar ---> a:\b.jar a:\c.jar

My question: how do I re-insert a grouping back into my string?

d:\>> echo "a:/b.jar:a:/c.jar" | sed -e"s/:\([A-Za-z]\)/ $1/g"
a:/b.jar :/c.jar

I am unable to re-insert my grouping back into the string.
I've tried \$1, $$1, ....

Thanks

Michael.

Greg Chicares

unread,
Jun 30, 2000, 3:00:00 AM6/30/00
to

Try \1 (backslash one).

C:>echo a:/b.jar:a:/c.jar | sed -e"s/:\([A-Za-z]\)/ \1/g"
a:/b.jar a:/c.jar

Same command works with backslashes in input:

C:>echo a:\b.jar:a:\c.jar | sed -e"s/:\([A-Za-z]\)/ \1/g"
a:\b.jar a:\c.jar

C:\JUNK>sed --version
GNU sed version 3.02

Copyright (C) 1998 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
[some windows port I picked up somewhere]

Other versions of sed might behave differently.

My sed bookmarks in case they're of use to you:

http://www.dreamwvr.com/sed-info/sed-faq.html

http://www.ptug.org/sed/sedfaq.html

http://seders.icheme.org/

http://www.dbnet.ece.ntua.gr/~george/sed/

http://www.bluesky.com.au:457/OSUserG/BOOKCHAPTER-14.html

http://www.gnu.org/manual/sed-3.02/html_mono/sed.html


Ken Pizzini

unread,
Jul 1, 2000, 3:00:00 AM7/1/00
to
On Fri, 30 Jun 2000 11:10:43 -0400,
Hanner, Michael [SKY:P062:EXCH] <mha...@americasm01.nt.com> wrote:
>This is what I want to to:
>
>a:\b.jar:a:\c.jar ---> a:\b.jar a:\c.jar
>
>My question: how do I re-insert a grouping back into my string?
>
>d:\>> echo "a:/b.jar:a:/c.jar" | sed -e"s/:\([A-Za-z]\)/ $1/g"

The "$1"-type notation is from perl; the sed way is "\1":


echo "a:/b.jar:a:/c.jar" | sed -e"s/:\([A-Za-z]\)/ \1/g"

--Ken Pizzini

0 new messages