How to get content of a variable into text file (sed)?

Hello,

Im working on this problem for 3 days now and i just cant get it to work.. I tried with alot of different sed methods but didnt find any solution. Its proberly verry simple but i just started bash scripting for a month or so..

i have a file called: file.nfo and file.txt
the content of file.nfo is

test23423
test 234
test3443
whole lot of text

the content of file.txt is

[nfo]nfotxt[/nfo]

I want to replace nfotxt with the content of the file.nfo
i do that with:

txtfile=file.txt
nfo=file.nfo
nfotext="$(cat "$nfo")"

then i use sed to search and replace like:

sed -e "s/nfotxt/$nfotext/g" $txtfile

i also did an escape \ or qoute "$nfotext"

The problem i have is that it doesnt replace the nfotxt with the content of the file.nfo and that it wil replace it with $nfotext rather then the content.. Hope someone can enlighten me or point me in the right direction..

what is the o/p of:

echo $nfotext

and how you want the o/p:

[nfo]test23423 test 234 test3443 [/nfo]

or

[nfo]test23423
test 234
test3443[/nfo]
what is the o/p?

the content of echo $nfotxt file is what i cat.

and how you want the o/p?

untouched..how it is in the nfo file.. Like this:
edited by scottn: LINK REMOVED

Not sure about the sed thing, but if you are okay with alternative solutions, then -

$ 
$ cat file.nfo
test23423
test 234
test3443
whole lot of text
$ 
$ cat file.txt
[nfo]nfotxt[/nfo]
$ 
$ perl -pi.bak -e "s/nfotxt/`cat file.nfo`/" file.txt
$ 
$ cat file.txt
[nfo]test23423
test 234
test3443
whole lot of text[/nfo]
$ 
$ 

tyler_durden

{
 printf "%s" "[nfo]"
 cat "file.nfo"
 printf "%s\n" "[/nfo]"
} > file.txt