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.

Required fields*

4
  • I'm actually replacing the inner text with an environment variable, which only works with double quotes as far as I can tell. Is there a way to insert an environment variable using single quotes? Commented Apr 2, 2020 at 3:17
  • end the single quotes, insert "$var", then open the single quotes again: 's~FOO~test\\"te'"$var"'st~g' Commented Apr 2, 2020 at 3:21
  • Unfortunately my variable contains double and single quotes (it's JSON), which seems to trip it all up. Commented Apr 2, 2020 at 3:23
  • Thanks - you put me on the right track. I had to super-escape my escaped quotes with sed -e 's~\\"~\\\\"~g'. Commented Apr 2, 2020 at 3:48