I have an XML file (config.xml) as below.
<?xml version="1.1" encoding="UTF-8"?> <project> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers> <com.cloudbees.jenkins.GitHubPushTrigger plugin="[email protected]"> <spec/> </com.cloudbees.jenkins.GitHubPushTrigger> </triggers> <concurrentBuild>false</concurrentBuild> </project> I want to replace the triggers block with only <triggers/>. But when I use SED to do it, I get this error:
sed: 1: "/<triggers>/{:a;N;/<\/t ...": unexpected EOF (pending }'s)
Command:
sed -i '.bak' '/<triggers>/{:a;N;/<\/triggers>/!ba;N;s/.*\n/<triggers\/>\n/};p' config.yml
I want you to know what am I missing here and how to get the desired outcome?
Desired Output:
<?xml version="1.1" encoding="UTF-8"?> <project> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> </triggers> <concurrentBuild>false</concurrentBuild> </project>
sed -e '/<triggers>/,/<\/triggers>/{/<\/triggers>/{i \ \ </triggers>' -e '};d}' file.xmlsed -e '/<triggers>/,/<\/triggers>/{/<\/triggers>/{i \ \ <triggers\/>' -e '};d}' file.xmlOutput:sed: 1: "/<triggers>/,/<\/trigge ...": extra characters after \ at the end of i command