title: How to use sed to search and replace text in a file that's compatible across platforms macOS & Ubuntu?
body: <p>I'm using this command</p>
  <pre><code>sed -i'' -e &quot;s/MARKETING_VERSION = 0.0.0;/MARKETING_VERSION = ${version//v};/&quot; -f ios/App/App.xcodeproj/project.pbxproj
  </code></pre>
  <p>to replace the text in that file. This works on Ubuntu, but on Mac it changes the file and also creates a new file in the same directory called &quot;project.bxproj-e&quot; which seems to be the original file.</p>
  <p>This command works on Mac:</p>
  <pre><code>sed -i '' &quot;s/MARKETING_VERSION = 0.0.0;/MARKETING_VERSION = ${version//v};/&quot; -f ios/App/App.xcodeproj/project.pbxproj
  </code></pre>
  <p>For it to work, I had to add a space after -i and remove the -e, however on Ubuntu I get this error:</p>
  <pre><code>sed: can't read s/MARKETING_VERSION = 3.0.0;/MARKETING_VERSION = 0.0.0;/: No such file or directory
  </code></pre>
  <p>I'm just looking for something that works on both envs.</p>
  <p>If it helps, sed --version gets me &quot;sed (GNU sed) 4.4&quot; on Ubuntu. On Mac sed --version throws an error, but I can get this from the man page: &quot;The sed utility is expected to be a superset of the IEEE Std 1003.2 (``POSIX.2'') specification.&quot; and also mentions that &quot;-E -I -a and -i are non-standard and may not be available on other operating systems&quot;. But I don't know how to do it without them.</p>