Something like that?
#!/bin/bash sed -e "s/$2/$3/g" <$1 >$1.$$ && cp $1.$$ $1 && rm $1.$$
Alternatively you can use a single command
sed -i -e "s/$2/$3/g" $1
as Ian suggested. I usually use the first form. I have seen systems where -i not supported (SunOS).
This will replace all instances of the second argument with the third, in the file passed as the first. For example, ./replace file oldword newword
Jonathan
source share