I need to do this using unix script or command
There is a xml file in /home/user/app/xmlfiles like
<book>
<fiction type='a'>
<author type=''></author>
</fiction>
<fiction type='b'>
<author type=''></author>
</fiction>
<Romance>
<author type=''></author>
</Romance>
</book>
I want to edit author type in fiction as local .
<fiction>
<author type='Local'></author>
</fiction>
I need to change the author type which is in fiction tag with attribute b alone.
Please help me with this using unix shell script or command. Thanks !
Best Answer
If you just want to replace
<author type=''><\/author>
with<author type='Local'><\/author>
, you can use thatsed
command:But, when dealing with xml, I recommend an xml parser/editor like xmlstarlet:
Use the
-L
flag to edit the file inline, instead to printing the changes.