An example of the JSON is something like
{"version":"0.5363"}
I'd need to be able to inject a new value for version thorugh a variable. I found one solution on stackoverflow which says:
echo '{"version":"0.5363"}' | sed 's/\({"version":"\)[^"]*\("}\)/\1newvalue\2/g'
But i wanted to replace the newvalue through varable i.e
echo '{"version":"0.5363"}' | sed 's/\({"version":"\)[^"]*\("}\)/\1$newvalue\2/g'
But is is replacing the string as
{"version":"$newvalue"}
The above example is refrenced one. Actually my JSON looks like below: "checksum": "sdkjjfj-shbdjfj23"
I wanted to replace the checksum value with another value. As per above I used : sed -i 's/("checksum": ")[^"]*(")/\1$checksumVal\2/g' new.json
The new.json is updated as below, but i wanted the value of that variable. "checksum": "$checksumVal",
Any help would be appreciated.