Reputation: 3
I need to replace the below string with null . Its basically an xml file and i want to omit the xmnls part using unix commands.
xmlns:stl="http://www.xxx.yy/1234/stl-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
I have tried using the below commands :
perl -pi -e "s+xmlns:stl="http://www.xxx.yy/1234/stl-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"++" filename.xml
sed 's+xmlns:stl="http://www.xxx.yy/1234/stl-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"++' filename.xml
Didnt work out well. :( Does the experts have any idea on how this should be handled.
PS: Its a continuous line having tags after the string
value xmlns:stl="http://www.xxx.yy/1234/stl-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
. So cannot delete the line
Upvotes: 0
Views: 589
Reputation: 530
Your sed
line works reasonably well, but:
sed -i
.To make it predictable, you need to escape regex special characters with \
, like this:
sed -i 's+xmlns:stl="http://www\.xxx\.yy/1234/stl-1\.0" xmlns:xsi="http://www\.w3\.org/2001/XMLSchema-instance"++' filename.xml
Upvotes: 1