SED without backup file

LA_ picture LA_ · Aug 25, 2014 · Viewed 22.2k times · Source

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

sed -i -e 's/noreply@\(.*\).example.com/[email protected]/' 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/[email protected]/' -i cron.yaml

but in this case sed returns an error.

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

Answer

Marco de Jongh picture Marco de Jongh · Aug 25, 2014

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

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