sed anomaly in bash script

David Stacey drstacey@tiscali.co.uk
Fri Nov 14 17:48:00 GMT 2014


On 14/11/14 17:20, cyg Simple wrote:
> $ TEST=`echo 'c:\windows' | sed -e s.\\.\\\\.g`
> $ echo $TEST
> c:\\windows
>
> <file name=sed.sh>
> TEST=`echo 'c:\windows' | sed -e s.\\\.\\\\\.g'
> echo $TEST
> </file>
>
> $ bash -x sed.sh
> ++ echo 'c:\windows'
> ++ sed -e 's.\.\g'
> sed -e expression #1, char 7: unterminated 's' command
> + TEST=
> + echo
>
> CYGWIN_NT-6.1 HOSTNAME 1.7.32(0.274/5/3) 2014-08-13 23:06 x86_64 Cygwin
>
> Does anyone have a suggestion on turning c:\windows into c:\\windows?

I don't have a Windows PC to hand ATM, but the following works in Fedora 
bash:

#!/usr/bin/bash
TEST=$(echo "c:\windows" | sed -e "s;\\\\;\\\\\\\\;g")
echo ${TEST}


Dave.


--
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



More information about the Cygwin mailing list