This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: sed anomaly in bash script
- From: Brian Inglis <Brian dot Inglis at SystematicSw dot ab dot ca>
- To: cygwin at cygwin dot com
- Date: Sat, 15 Nov 2014 04:40:59 +0000 (UTC)
- Subject: Re: sed anomaly in bash script
- Authentication-results: sourceware.org; auth=none
- References: <CABa6CE=OFjPjomA9xQESG==MTjP9y=5UqeTgtg4fxnZjYqTEuw at mail dot gmail dot com>
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