macosbashsedosx-mavericks

SED without backup file


I use the following sed command to replace text in the file:

sed -i -e 's/noreply@\(.*\).example.com/noreply@example.com/' cron.yaml

But it create backup of the file cron.yaml under name cron.yaml-e.

I tried to move -i to the end:

sed -e 's/noreply@\(.*\).example.com/noreply@example.com/' -i cron.yaml

but in this case sed returns an error.

How should I modify my command line to avoid backup file creation?


Solution

  • According to the man page you should specify a zero length extension on macOS

    sed -i '' -e 's/noreply@\(.*\).example.com/noreply@example.com/'