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.
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://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
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