Requirements are as follows:
Original<Servername= "92 Service"Port= "10092"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID=""tabname= "Regional Service"/> <Servername= "93 Service"Port= "10093"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID=""tabname= "Regional Service"/> <Servername= "94 Service"Port= "10094"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID=""tabname= "Regional Service"/> <Servername= "95 Service"Port= "10095"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID=""tabname= "Regional Service"/> <Servername= "96 Service"Port= "10096"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID=""tabname= "Regional Service"/>into<Servername= "92 Service"Port= "10092"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID= "10092"tabname= "Regional Service"/> <Servername= "93 Service"Port= "10093"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID= "10092"tabname= "Regional Service"/> <Servername= "94 Service"Port= "10094"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID= "10092"tabname= "Regional Service"/> <Servername= "95 Service"Port= "10095"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID= "10092"tabname= "Regional Service"/> <Servername= "96 Service"Port= "10096"OS= "Android"Hidden= "false"recommendrate= "0"Newport=""ZoneID= "10092"tabname= "Regional Service"/>The requirement is to fill the ZoneID according to the Port
Use SED to reference the following method:
[Root]$ Cat SetZone.txt | Sed-e's/\ (port= "\) \ ([0-9]+\) \ (. *\) \ (zoneid=" \)/\1\2\3\4\2/g'<server name="92 Service"port="10092"os="Android"hidden="false"Recommendrate="0"newport=""Zoneid=""Tabname="Regional Service"/><server name="93 Service"port="10093"os="Android"hidden="false"Recommendrate="0"newport=""Zoneid=""Tabname="Regional Service"/><server name="94 Service"port="10094"os="Android"hidden="false"Recommendrate="0"newport=""Zoneid=""Tabname="Regional Service"/><server name="95 Service"port="10095"os="Android"hidden="false"Recommendrate="0"newport=""Zoneid=""Tabname="Regional Service"/><server name="96 Service"port="10096"os="Android"hidden="false"Recommendrate="0"newport=""Zoneid=""Tabname="Regional Service"/>
"Shell" sed back to reference replace text