Batch file : Replace part of txt file

September 27, 2010 at 06:08:32
Specs: Windows 7
Hello,

I have 2 files, config.xml and newconfigui.xml.

somewhere in the middle of config.xml i have the following :

<UI>
bla1
bla2
bla3
</UI>

newconfingUI.xml only holds new ui data:
new1
new5
new9
new2

i want to remove all strings within UI tag on config.xml and replace them with newconfigUI.xml strings, and not touch rest of the config.xml file, how ?!


See More: Batch file : Replace part of txt file

Report •


#1
September 27, 2010 at 06:45:54
download gawk for windows then do this

FNR==NR{s=s"\n"$0}NR>FNR && /<UI>/{print $0"\n"s;f=1 }
NR>FNR && !f{print}
NR>FNR && /<\/UI>/{f=0; print "</UI>"}

Save the above as myscript.awk and on command line

C:\test>gawk -f test.awk newconfigui file

GNU win32 packages | Gawk


Report •
Related Solutions


Ask Question