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
  • So I am unable to use the first printf option - 2nd is good and I tried a bit but same issue, I get the string that I can pass through sed or perl to get to your format but then interpolation doesn’t work. My real constraint is I get an arbitrary json with ${xyz} in between that I don’t know in advance. I get str and then have to ensure its interpolated but other characters preserved as is. Commented Jun 2, 2021 at 19:26
  • What I've written generates the output you've described. If you want to do something else please edit your question to show what you really want to do Commented Jun 2, 2021 at 19:29
  • 1
    The correct tool is probably jq Commented Jun 2, 2021 at 19:33
  • Thank you, I added a constraint that the example is just to illustrate some code. The actual json is not known in advance and can be arbitrary. Commented Jun 2, 2021 at 19:40
  • ... jq or jo Commented Jun 2, 2021 at 20:45