Help with template like solution

hi experts,

i'm trying to do this:

file1 is a template. might have kinds of 'funny' characters.
sample:

<body>
<form>
<p><input type="text" name="abc"/></p>
�
<p><my_content></p>
</form>
</body>

file2 is a file that contains lots of text. this might be very big. might have 'funny' characters as well.
sample:

<tr><td align="center">1.1</td><td>1.2</td></tr>
... many many lines ...
<tr><td align="center">2000.1</td><td>2000.2</td></tr>

my question is, how do i read file1, replace <my_content> with the content of file2, and store/print out the result?

i've tried to use sed, i firstly escape the content of file2, these characters: \ &
then i use sed substitute. but when file2 gets very big, sed would display error that the parameter is too long.

any suggestions on how to do this? i do not need the regex feature. just search that <my_content> and replace it with the content from file2.

thanks for the help.

Hope you can modify your template like (so that "<my_content>" has its own line).

<body>
<form>
<p><input type="text" name="abc"/></p>
�
<p>
<my_content>
</p>
</form>
</body>

Then this works (takes everything before "<my_content>" , the file2 and then everything after "<my_content>" )

#!/bin/bash
{   sed -n '1,/\<my_content\>/p' file1 | sed '$d'
    cat file2
    sed -n '/\<my_content\>/,//p' file1 | sed '1d'
} > file3

If "<my_content>" is an html comment, you can remove everything after the pipes in the script, it will leave the comment in the output file as markers to see where you've put your data.

An AWK solution :

awk '
   NR==FNR { string = string $0 "\n" ; next}
   { gsub(/<my_content>/, string) ; print }
' file2 file1

Jean-Pierre.