Quantcast
Channel: Inserting a text between 2 patterns - Unix & Linux Stack Exchange
Browsing index pages (4 articles)

Inserting a text between 2 patterns

I have a .xml file which contains the below <controller-host></controller-host> <controller-port></controller-port> <tier-name></tier-name>...

View Article


Answer by Kira for Inserting a text between 2 patterns

You can try something like this: $host='hostname' sed -i 's/<controller-host><\/controller-host>/<controller-host>AppDynamicsHost<\/controller-host>/' yourfile.xml sed -i...

View Article


Answer by chaos for Inserting a text between 2 patterns

The file that is given is not valid xml. You have to add opening and closing root tags. Like this: <xml> <controller-host></controller-host>...

View Article

Answer by cas for Inserting a text between 2 patterns

As chaos said, making the file a valid XML file and using xmlstarlet or similar xml processing tool (e.g. xsh) is the "right" answer...but if you just want to do simple templating then you would modify...

View Article
Browsing index pages (4 articles)


Latest Images