bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sed - problem with escape charecters in cygwin


From: Cullen Davidson
Subject: sed - problem with escape charecters in cygwin
Date: Wed, 20 Nov 2002 07:48:28 -0800 (PST)

There appears ot be a bug in the sed function that requires the use of
two backslashes '\\' to escape characters in the regexp of a command
line substitution. The single backslash is simply ignored entirely as far
as I can tell. The replacement string does not have this problem, it
seems to work normally. Here is an example:

sed "s!\.properties!\.config!" file.txt

This will should only locate the literal string '.properties' but it is
not escaping the '.' and therefore replacing any instance of the sting
"properties" and it's preceding character as it treats the '.' as a
wild-card.

so....

file.properties --> file.config (good)

#my properties file --> #myconfig file (bad)

The solution (work-around) is to use a double-backslash. For whatever
reason this seems to react as if there is only one. The obvious problem
here being that you have to convert any scripts that use sed to cigwyn,
an annoyance to anyone using UNIX and cygwin in a development
environment.

sed "s!\\.properties!\config!" file.txt

file.properties --> file.config (good)

#my properties file --> #my properties file (good)

Thanks,
cullen



Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
reply via email to

[Prev in Thread] Current Thread [Next in Thread]