I am working on a simple script to prepend part of the pattern match for all lines between matches.

For example:

```
matchline_VAR
name1 xxx yyy zzz
name2 aaa bbb ccc
matchline_VAR

```

needs to become (if simple remove matchlines if not I can post-process to remove them):

```
VAR_name1 xxx yyy zzz
VAR_name2 aaa bbb ccc

```

Right now I am attempting in sed like so:

```
sed '/matchline_\(.*$\)/,/matchline_/ {s/^/\1_/g}'

```

It is instead just printing a 1 in front of the lines. 

Perhaps I should also mention that this is part of a larger script to search through a text file and replace each instance of a shell variable $find (one line) with another shell variable $replace (multiple lines). The current solution is:

```
awk -v find="$find" -v replace="$replace" '$0==find{$0=replace}1' file

```

The problem is that I need to append the first field in $find to each line of $replace
I tried:

```
awk -v find="$find" -v replace="$replace" '$0==find{$0="matchline_" $1 "_" replace}1'

```

but it only appends the name at the start of the multiline $replace.

Any help is appreciated,

John