Reputation: 653
I want to replace the host id in number of files and the host id is different in each file, so I have to replace the content between the tags <hostid>
and </hostid>
, each file has only one <hostid>
line
<hostid>71342-231VMKDK-47WW-03dMV6</hostid>
to
<hostid>xxxx-yyyyy-zzz-uuu-bb</hostid>
I did try something like below which didn't work
sed -i "" -e :a -e 's/\(hostid>[X]*\)[^X]\(.*<\)/\1\something\</;ta'
Upvotes: 0
Views: 54
Reputation: 133760
Could you please try following.
sed '/hostid/s/>.*</>xxxx-yyyyy-zzz-uuu-b</' Input_file
In case you want to save output into Input_file itself along with taking backup of Input_file then change sed
to sed -i.bak ...
.
Upvotes: 1