I've looked around to find a solution to my problem in other posts listed bellow, but it looks my regex is quit different and need special care: How to output only captured groups with sed Replace one capture group with another with GNU sed (macOS) 4.4 sed replace line with capture groups
I'm trying to replace a regex match group in big JSON file, My file has mongoDB exported objects, and I'm trying to replace the objectId with the string:
{"_id":{"$oid":"56cad2ce0481320c111d2313"},"recordId":{"$oid":"56cad2ce0481320c111d2313"}}
So the output in the original file should look like this: {"_id":"56cad2ce0481320c111d2313","recordId":"56cad2ce0481320c111d2313"}
That's the command I run in the shell:
sed -i 's/(?:{"\$oid":)("\w+")}/\$1/g' data.json
I get no error, but the file remains the same. What exactly am I doing wrong?