LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can sed (or any other such utility) replace `x\"y' with `x\\\"y'? (http://www.linuxquestions.org/questions/linux-newbie-8/how-can-sed-or-any-other-such-utility-replace-%60x%5C-y-with-%60x%5C%5C%5C-y-642002/)

lumix 05-13-2008 07:55 PM

How can sed (or any other such utility) replace `x\"y' with `x\\\"y'?
 
The problem is that I need to turn

Code:

x\"y
into

Code:

x\\\"y
because when I echo the string I still need an escaped quote left over. Echo de-escapes the
Code:

\"
part of it so I need to escape the escape, er, sorta.

pixellany 05-13-2008 09:05 PM

Code:

echo 'x\"y' | sed 's/x\\"y/x\\\\\\"y/'
x\\\"y

You were right--you have to "escape the escapes"---"\\" means a literal "\"


All times are GMT -5. The time now is 10:07 PM.