I have a file that contains multiple lines of xml. I would like to replace certain parts of the file. Some parts of the file contains quotation marks ("
) which I would like to replace. I have been trying to escape the quotation mark with \
, but I don't think this is working based on the result of my file.
Here is an example of one of my sed commands:
sed -e "s/\"text\"/'text'/ig" file.xml > temp.tmp
Is this how you escape quotation marks in a sed command or am I doing something wrong?
"text"
with'text'
. Of course it won't do anything to"othertext"
. Show a few input lines, the corresponding undesired output, and explain what output you want instead.\"
is the correct way of escaping quotation marks in sed command?"
. But your shell command uses a double-quoted string, and\"
is correct there. Thesed
program seess/"text"/'text'/ig
as the argument to-e
.s/\"text\" /'text'/ig
Would it find only"text"
with the space after it?sed
is the right tool for the job, maybe you want an XML parser.