The simplest way to proceed is to use sed.
It‘s available both on Mac and Linux. Here is the gist of it:
sed -i 's/old/new/g' file.txtHere we’re replacing old with new.
The -i option will replace the string inplace. The /g flag will replace every occurrences in the file.
@nepsilon Doesn't work for me on macOS:
This does, but creates that backup file (which I think
-imay expect as an argument):