I think sed is probably what you want to use - that or Perl
Sed docs:
http://www.gnu.org/software/sed/manual/sed.html
Since you specified bash scripting, that is probably the easiest.
Here's a thread with a nice example:
http://www.unix.com/shell-programmin...same-file.html
You would just recast that example specified to use your RANDOM STRING.
The basic concept is sed -i.suffix 's/(regexp to find your string)/(new value)/g' filename