sed

To replace content of file in unix / linux, use sed.

Basic use, first try outputting to terminal:

sed s/blue/black/ file.txt

you can then do either

sed s/blue/black/ file.txt > replaced.txt
or
sed -i s/blue/black/ file.txt

Last command makes changes directly to file.

If you need to use non-alphabetic-characters, use \ – char in front of them. For example:

sed s/file\.txt/nonfile\.txt/ filetoreplace

More, much more : http://www.grymoire.com/Unix/Sed.html#uh-8