Portable Cygwin: replacing drivename in a text file
Thu Nov 25 14:43:00 GMT 2010
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.
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).
> 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
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin