RE: Portable Cygwin: replacing drivename in a text file

2010-11-26 Thread Buchbinder, Barry (NIH/NIAID) [E]
Andrew DeFaria sent the following at Thursday, November 25, 2010 10:15 AM > On 11/25/2010 09:35 AM, Alexandre Bezroutchko wrote: >>> you can use a different separator in the sed command. >>> You can use the following line >>> >>> echo 123 | sed "s%2%${HOME}%g" >> >> Right, this will work in most

Re: Portable Cygwin: replacing drivename in a text file

2010-11-25 Thread Andrew DeFaria
On 11/25/2010 09:35 AM, Alexandre Bezroutchko wrote: you can use a different separator in the sed command. You can use the following line echo 123 | sed "s%2%${HOME}%g" Right, this will work in most cases. But will fail if $HOME happens to contains % sign. The version I have suggested in

Re: Portable Cygwin: replacing drivename in a text file

2010-11-25 Thread Alexandre Bezroutchko
you can use a different separator in the sed command. You can use the following line echo 123 | sed "s%2%${HOME}%g" Right, this will work in most cases. But will fail if $HOME happens to contains % sign. The version I have suggested in the previous post is more robust. Best regards, Alex

Re: Portable Cygwin: replacing drivename in a text file

2010-11-25 Thread Dirk Fassbender
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 ww

Re: Portable Cygwin: replacing drivename in a text file

2010-11-25 Thread 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:

Re: Portable Cygwin: replacing drivename in a text file

2010-11-25 Thread Fergus
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

Re: Portable Cygwin: replacing drivename in a text file

2010-11-24 Thread Lee
On 11/24/10, Fergus wrote: > Running Cygwin off a portable USB stick. > > Different host machines typically allocate a different drivename to the > stick. > > Previous use, say it was J:. A not-quite-portable application needed a > settings.ini file built with many occurrences of the string > j:\

Re: Portable Cygwin: replacing drivename in a text file

2010-11-24 Thread Alexandre Bezroutchko
I'm not the expert on cygwin.exe, but there might be an easier way to solve you problem. For POSIX shell scripts you could keep a symlink /my-usb-stick pointing to /cygdrive/X, and use that symlink in your scripts. Similarly, for Windows batch scripts you keep drive mapping with native Windows

R: Portable Cygwin: replacing drivename in a text file

2010-11-24 Thread Marco Atzeri
--- Mer 24/11/10, Fergus ha scritto: > Running Cygwin off a portable USB > stick. > > Different host machines typically allocate a different > drivename to the stick. > > Previous use, say it was J:. A not-quite-portable > application needed a settings.ini file built with many > occurrences of t

Portable Cygwin: replacing drivename in a text file

2010-11-24 Thread Fergus
Running Cygwin off a portable USB stick. Different host machines typically allocate a different drivename to the stick. Previous use, say it was J:. A not-quite-portable application needed a settings.ini file built with many occurrences of the string j:\usr\local\bin. The file was built and