Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    Your command looks right for replacing "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. Commented Mar 20, 2011 at 19:11
  • So \" is the correct way of escaping quotation marks in sed command? Commented Mar 20, 2011 at 19:15
  • 4
    Not for sed: sed doesn't need, or support, escaping ". But your shell command uses a double-quoted string, and \" is correct there. The sed program sees s/"text"/'text'/ig as the argument to -e. Commented Mar 20, 2011 at 19:20
  • @Gilles What about spaces? Does sed understand and respect white spaces? For instance, if my command contained s/\"text\" /'text'/ig Would it find only "text" with the space after it? Commented Mar 20, 2011 at 19:24
  • 3
    Spaces must match exactly. Rather than continue this dialogue, I recommend that you post some sample input and the corresponding desired output (and perhaps explain why you need to change the quoting). It's not even clear that sed is the right tool for the job, maybe you want an XML parser. Commented Mar 20, 2011 at 19:28