X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_20,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-08.arcor-online.net 959E12057C4 Message-ID: <4CEE6FAF.5080405@arcor.de> Date: Thu, 25 Nov 2010 15:16:15 +0100 From: Dirk Fassbender <dirk DOT fassbender AT arcor DOT de> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.12) Gecko/20101027 Lightning/1.0b2 Thunderbird/3.1.6 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Portable Cygwin: replacing drivename in a text file References: <4CEE6175 DOT 2030805 AT bonhard DOT uklinux DOT net> <4CEE64C5 DOT 2080007 AT gremwell DOT com> In-Reply-To: <4CEE64C5.2080007@gremwell.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: <cygwin.cygwin.com> List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com> List-Archive: <http://sourceware.org/ml/cygwin/> List-Post: <mailto:cygwin AT cygwin DOT com> List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Am 25.11.2010 14:29, schrieb Alexandre Bezroutchko: > Hi Fergus, > > The problem is $HOME contains '/' character used as delimited in > regex. You need to escape it first: > > HOME_ESCAPED=`echo "$HOME" | sed 's#/#\\\\/#g'` > echo 123 | sed "s/2/$HOME_ESCAPED/g" > > It is not cygwin-specific. > > Cheers, > Alex > www.gremwell.com > > On 11/25/2010 02:15 PM, Fergus wrote: >>> I can't get the syntax quite right. >>> Can anybody help, please? Thank you very much. >> >> Thanks very much indeed for various suggestions, much appreciated. I >> guess by yakking on about "drivename" I moved the focus of my question >> to its practical application and thereby managed to blur things. My real >> question is >> >> Given the string 123 how can I use sed to change it to 1$HOME3 or, in my >> case, 1/home/user3. Various combinations of ' " and ` (also arbitrary >> separators) all fail as in >> >> echo 123 | sed 's/2/"$HOME"/g' >> echo 123 | sed 's/2/`$HOME`/g' >> echo 123 | sed "s/2/'"$HOME"'/g" >> echo 123 | sed 's/2/@$HOME@/g' >> >> Thank you (again). >> >> Fergus >> >> >> >> -- >> Problem reports: http://cygwin.com/problems.html >> FAQ: http://cygwin.com/faq/ >> Documentation: http://cygwin.com/docs.html >> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple >> > > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > > > Hello Fergus, you can use a different separator in the sed command. You can use the following line echo 123 | sed "s%2%${HOME}%g" Regards Dirk -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple