Quantcast
Channel: Inserting a text between 2 patterns - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 4

Answer by Kira for Inserting a text between 2 patterns

$
0
0

You can try something like this:

$host='hostname'

sed -i 's/<controller-host><\/controller-host>/<controller-host>AppDynamicsHost<\/controller-host>/' yourfile.xml
sed -i 's/<controller-port><\/controller-port>/<controller-port>80<\/controller-port>' yourfile.xml
sed -i "s/<tier-name><\/tier-name>/<tier-name>${host}<\/tier-name>/' yourfile.xml
sed -i 's/<node-name><\/node-name>/<node-name>tomcat server<\/node-name>/' yourfile.xml

The -i flag means to write the result into your file, try running this without the -i while testing.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>