I would like to take the following:
'{\"apiVersion\":\"apps/v1\", \"kind\":\"two\"}'
And end up with the following via using SED:
{'apiVersion':'apps/v1', 'kind':'two'}
CodePudding user response:
Suggesting to try:
echo '{\"apiVersion\":\"apps/v1\", \"kind\":\"two\"}'|sed "s|\\\\\"|\'|g"
Result:
{'apiVersion':'apps/v1', 'kind':'two'}
CodePudding user response:
Using Bash's string replace:
#!/usr/bin/env bash
a='{\"apiVersion\":\"apps/v1\", \"kind\":\"two\"}'
# Replaces all occurrences of \" with '
b=${a//\\\"/\'}
# Debug prints converted string
printf '%s\n' "$b"