sed anomaly in bash script
Brian Inglis
Brian.Inglis@SystematicSw.ab.ca
Sat Nov 15 04:41:00 GMT 2014
cyg Simple <cygsimple <at> gmail.com> writes:
> $ 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
> Does anyone have a suggestion on turning c:\windows into c:\\windows?
$ t='c:\windows' ; tt=${t/\\/\\\\} ; echo $t $tt
c:\windows c:\\windows
Never ever use odd numbers of backslashes, when dealing with backslashes! ;^>
"\\" is the character backslash, doubled for each layer of interpretation it
has to pass thru before it gets to where it's going.
--
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