I have looked all over but can't find a sed or other command to do the following:

Search for whats between the tags and replace with a String.

```
<version.of.artifact>1.2.3</version.of.artifact>

```

Sounds easy enough but cannot find a command that does both.

I am able to find and print value with:

```
sed -n 's:.*<version.of.artifact>\(.*\)</version.of.artifact>.*:\1:p' myFile.txt

```

But I want to replace the value (1.2.3) with another value.

Any help would be appreciated.

Solved - and updated answer below use variables:

```
sed -i "s:\(<$var1>\)[^<]*\(</$var1>\):\1$var2\2:" pomtest.xml

```