The java build tool ant provides filter to replace variables by their values
Example: A file with properties:
db.user.name=user
db.driver=com.informi
This is an other implementation using bash only. If you can take the python version for you need I would suggest that. It will be easier to maintain. Otherwise you could try with this bash script:
#!/bin/bash
config="$1"
xml="$2"
tmp=$(mktemp)
cat "$config" | while read line; do
key=`echo $line | sed -n 's/^\([^=]\+\)=\(.*\)$/\1/p'`
value=`echo $line | sed -n 's/^\([^=]\+\)=\(.*\)$/\2/p'`
echo " sed 's/@$key@/$value/g' | " >> $tmp
done
replacement_cmd=`cat $tmp`
eval "cat \"$xml\" | $replacement_cmd cat"
rm -f $tmp