You could try using 'sed'...
To replace 'bob' with whatever's in the variable $jim, do:
#/bin/sh
jim=<some-calculation>
cat <filename> | sed "s/bob/$jim/g"
It's a lot nicer...
NB: If $jim contains '/' characters, do this instead:
cat <filename> | sed "s/bob/$(echo $jim | sed 's/\//\\\//g')/g"
... ok... maybe it's not that nice
Remember, double quotes are needed if a variable is to be expanded inside them.