I need using the Sed to update some string in the Json files. However, due to the presence of special characters in the field, the replacement has not been successful:
The string which should be replaced is:
"[parameters('test-test_properties_typeProperties')]"
And I want to replace it to {}
My test code like:
sed -i "s/'"[parameters('test-test_properties_typeProperties')]"'/{}/g" $(Build.Repository.LocalPath)/ARMTemplate/ARMTemplateParametersForFactory.json
or
sed -e "s|"'['parameters'(''test-test_properties_typeProperties'')'']'"|{}|g" $(Build.Repository.LocalPath)/ARMTemplate/ARMTemplateForFactory.json
Both not work for me, please help.
2
This should work for you:
sed -i "s/[parameters('test-test_properties_typeProperties')]/{}/g" file.json
Important to note that we need to escape the starting [
here to tell sed program to not to treat it as bracket expression which is otherwise like [aeiou]
.