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.
@josephgrossberg Good catch! My example seems to work only with GNU sed, not the BSD sed which is pre-installed on Mac.
The BSD sed needs a value to its
-ioption, to specify the extension of the backup file.