Simple Shell Script! Almost Done!

Hello, I am creating a shell script and I am almost done. I have certain things I want done in the shell but don't know how to finish it properly.

Here is what I am aiming to do. I am aiming to have a shell that takes at least 3 parameters. The first two are the two words to replace (the first being the word replaced and the second being the word to replace it with) and then the third (and beyond) parameter, are all the files to make the changes to.

Here is what I have so far but its not working correctly and giving me incorrect output when using special characters such as changing 'Unix' to 'U N I X'

#!/bin/sh

replace=$1
shift
with=$1
shift
for file in $*
do
   echo $file

newreplace=`echo "$replace" | sed -e "s/$replace/&/g"`

echo $newreplace

sed "s/$newreplace/$with/g" "$file" > "$file.updated"
mv "$file.updated" "$file"
done

Given your 'Unix' to 'U N I X' example, it works for me. I'm a bit unsure what you are trying to accomplish with this statement:

newreplace=`echo "$replace" | sed -e "s/$replace/&/g"`

Maybe you're just debugging with it, but you're replacing the string with itself which doesn't (to me) seem useful.

Please post a sample of your input, what you expect the result to be, and what you are actually getting. That might help someone here figure out what is going on. Also, the version of your O/S, sed, and shell might be useful to know too.

Here would be the 4 parameters.

'Unix 'U N I X' '_king cobra.dat' '_ne$wt.foo'

That would replace the word Unix with U N I X in the files _king cobra.dat and _ne$wt.foo

When doing it, for whatever reason, it is saying I have the incorrect output for those parameters.

How do I find my version of O/S, sed and shell?

why you are creating newreplace variable