Thursday, October 28, 2021

[SOLVED] How to replace a string using Sed?

Issue

Suppose I have a string like this

<start><a></a><a></a><a></a></start>

I want to replace values inside <start></start> like this

<start><ab></ab><ab></ab><ab></ab><more></more><vale></value></start>

How do I do this using Sed?


Solution

Try this :

sed 's@<start>.*</start>@<start><ab></ab><ab></ab><ab></ab></start>@' file


Answered By - Gilles Quenot