Hello,
I have below xml file, I want to find line default-value
and replace the string within quotes followed by default-value
"moni/Websphere/"
. Replace moni/Websphere/
with monitor/AMQ/
<monitor>
<name>WebsphereMqMonitor</name>
<type>managed</type>
<argument name="config-file" is-required="false" default-value="moni/Websphere"/>
</java-task>
</monitor-run-task>
</monitor>
What have you tried to solve this problem?
What operating system are you using?
What shell are you using?
1 Like
bash-3.2$ sed "s/default-value.*/default-value=\"monitor\/AMQ\"\/>/" t.txt
<monitor>
<name>WebsphereMqMonitor</name>
<type>managed</type>
<argument name="config-file" is-required="false" default-value="monitor/AMQ"/>
</java-task>
</monitor-run-task>
</monitor>
1 Like
RudiC
December 15, 2015, 5:51am
4
Above will replace every occurrence of a default value. Make it a bit more specific:
sed "/default-value/ s/moni\/Websphere/monitor\/AMQ/" file
1 Like
looney
December 16, 2015, 12:50pm
5
Download Notepad ++ , it will make life simpler. It supports Regular Expressions Which Notpad doesn't. Refer the attached pic