I have more than 1k xml files and in a loop I want to do few changes to xml file
original
<annotation>
<folder>VOC2014_instance/person</folder>
<filename>set00_V000_69.jpg</filename>
<source> ... </source>
....
....
</annotation>
modified should look like
<annotation>
<folder>VOC2014_instance/person</folder>
<filename>set00_V000_69.jpg</filename>
<path>/home/red/MyDataset/set00_V000_69.jpg</path>
<source> ... </source>
....
....
</annotation>
So, I tried writing this code
for file in $PWD/*.xml
do
sed -i 's/filename>/[\n] <path></path>/g' $file
done
What I'm doing is finding filename> and then append new line with \n + 4 spaces + <path>/home/red/$filename</path> + newline
I know I'm not doing it right but first I don't how to pick name of file b/w and then append a new line at end with space