Quantcast
Viewing latest article 15
Browse Latest Browse All 16

Answer by dnadlinger for sed in-place flag that works both on Mac (BSD) and Linux

This works with GNU sed, but not on OS X:

sed -i -e 's/foo/bar/' target.filesed -i'' -e 's/foo/bar/' target.file

This works on OS X, but not with GNU sed:

sed -i '' -e 's/foo/bar/' target.file

On OS X you

  • can't use sed -i -e since the extension of the backup file would be set to -e
  • can't use sed -i'' -e for the same reasons—it needs a space between -i and ''.

Viewing latest article 15
Browse Latest Browse All 16

Trending Articles