xml value chnage, need help

Group, I have a xml file like this.

<roll no="32" Name="test" home="AZ" Type="par">
<Info cid="5">

I have to change the "roll no" to a different value say, 66

i.e. required output:

<roll no="66" Name="test" home="AZ" Type="par">
<Info cid="5">

Please help. Anything with sed or awk will work

I tried this

$ MYID=66; sed -e 's+\(roll no=\)\([0-9]*\).*+\1"'$MYID'">+' my.xml
<roll no="66">
<Info cid="5">

But Name, home and Type got dis-appeared.

HTH,
jkl_jkl

Drop the .* in the regex string. Drop the > in the replacement string.

MYID=66; sed -e "s+\(roll no=.\)\([0-9]*\)+\1$MYID+" my.xml

vino, thats a real quick one from you. Thanks a lot :slight_smile: