Insert file contents into another file at a given position

I'm trying to write a small shell script/command to insert the contents of one file into another file at a position marked with a given text string. It's not necessarily at the top or bottom of the file so I can't just use cat to cat the files together.

I think probably sed with the r option is what I want to use but not sure. Any ideas would be appreciated.

Thanks
Shaun

Can you give any example ?

sed '/SEARCHSTRING/r newfile' inputfile

cheers,
Devaraj Takhellambam

Hi Devaraj

Fantastic!! That's almost exactly what I want. Can I get rid of SEARCHSTRING at the same time or is that a case of piping the output of this command to another sed to do something like sed '/SEARCHSTRING//' ?

Thanks
Shaun

sed -e '/SEARCHSTRING/r newfile' -e 's/SEARCHSTRING//' inputfile

cheers,
Devaraj Takhellambam

Thanks Devaraj that's exactly what I wanted.

Shaun