Use sed to replace a string in a files:
# Replace string 'aaa' with 'bbb' in file.txt
sed -i "s/aaa/bbb/g" file.txt
# another example
sed -i "s:\(soaservices.dir=\).*:\1$WORKSPACE:" services.properties
sed -i "s:\(-Dtangosol.coherence.clusteraddress=\)[0-9]*.[0-9]*.[0-9]*.[0-9]*:\1${coherence_address}:" ${domain_home}/bin/setDomainEnv.sh
xargs - build and execute command lines from standard input
# Use grep as the input
grep -l $old_server ${domain_home}/bin/* ${domain_home}/config/config.xml ${domain_home}/init-info/* | xargs sed -i "s/${old_server}/${new_server}/g"