I have big XML which i want to change all VERSIONNUMBER equal to 1,in existing file values of VERSIONNUMBER will be different as below now i want to change all VERSIONNUMBER values qual to 1.Please help me which will convert versionnumber values.
<SHORTCUT OBJECTSUBTYPE ="" OBJECTTYPE VERSIONNUMBER ="2"/>
< OBJECTTYPE REPOSITORYNAME ="" VERSIONNUMBER ="4"/>
REFERENCETYPE ="LOCAL" VERSIONNUMBER ="1"/>
REFERENCETYPE ="LOCAL" VERSIONNUMBER ="2"/>
<CONFIG DESCRIPTION ="Default VERSIONNUMBER ="1">
OUTPUT:
<SHORTCUT OBJECTSUBTYPE ="" OBJECTTYPE VERSIONNUMBER ="1"/>
< OBJECTTYPE REPOSITORYNAME ="" VERSIONNUMBER ="1"/>
REFERENCETYPE ="LOCAL" VERSIONNUMBER ="1"/>
REFERENCETYPE ="LOCAL" VERSIONNUMBER ="1"/>
<CONFIG DESCRIPTION ="Default VERSIONNUMBER ="1">
joeyg
November 5, 2013, 9:41am
2
So, you just want to change
VERSIONNUMBER ="2"
to
VERSIONNUMBER ="1"
throughout the entire file?
vbe
November 5, 2013, 9:45am
3
Since no script was given, moved to dummies...
yes,it should change complete file.in file it may be any value for versionnumber but command/script should change all values to one.
Hello,
Could you please try the following code. Let's say change_number is the file which have input data.
awk -vs1="VERSIONNUMBER ="1"" '/VERSIONNUMBER =/ gsub(/VERSIONNUMBER ="2"/,s1)' change_number
Output will be as follows.
<SHORTCUT OBJECTSUBTYPE ="" OBJECTTYPE VERSIONNUMBER =1/>
< OBJECTTYPE REPOSITORYNAME ="" VERSIONNUMBER ="4"/>
REFERENCETYPE ="LOCAL" VERSIONNUMBER ="1"/>
REFERENCETYPE ="LOCAL" VERSIONNUMBER =1/>
<CONFIG DESCRIPTION ="Default VERSIONNUMBER ="1">
Thanks,
R. Singh
CarloM
November 5, 2013, 3:35pm
6
$ sed 's/VERSIONNUMBER[ ]*="[^"]*"/VERSIONNUMBER ="1"/g' file.xml > newfile.xml