Hi All,
I have xml file,i am tring to use awk to search pattern as: <Password>x</Password>
and Replace with:
<Password>y</Password>
please any one can help to solve this using awk and awk only.
Hi All,
I have xml file,i am tring to use awk to search pattern as: <Password>x</Password>
and Replace with:
<Password>y</Password>
please any one can help to solve this using awk and awk only.
$
$ cat sample.xml
<?xml version="1.0"?>
<Member>
<User Id=100>
<Username>abc</Username>
<Password>x</Password>
</User>
<User Id=101>
<Username>def</Username>
<Password>y</Password>
</User>
<User Id=102>
<Username>pqr</Username>
<Password>z</Password>
</User>
</Member>
$
$
$ awk '{sub("<Password>x</Password>", "<Password>y</Password>"); print}' sample.xml
<?xml version="1.0"?>
<Member>
<User Id=100>
<Username>abc</Username>
<Password>y</Password>
</User>
<User Id=101>
<Username>def</Username>
<Password>y</Password>
</User>
<User Id=102>
<Username>pqr</Username>
<Password>z</Password>
</User>
</Member>
$
$
tyler_durden
the code not working proberly
more sample.xml|awk '{sub("<Password>x</Password>", "<Password>y</Password>"); print}'
awk: syntax error near line 1
awk: illegal statement near line 1
Note: i run this code on solaris
Try it using nawk instead of awk.
sed 's/<Password>x<\/Password>/<Password>y<\/Password>/' sample.xml