0

How can I make this work on macOS terminal?

sed -i 's/config.action_mailer.default_url_options =.*$/config.action_mailer.default_url_options = {:host => "localhost:3000"}/g' config/environments/development.rb
sed: 1: "config/environments/dev ...": command c expects \ followed by text
steeldriver
  • 81,074

1 Answers1

1

The problem you are experiencing is that the next argument after -i is being used as the string to add to a backup copy of the source file. the correct syntax is like:

sed -i '.BAK' 'command' file

The missing .BAK leaves the next argument: config/… as the command to execute and sed try (and fail) to execute the c command (first letter of command).

So, this is an exact duplicate of How can I achieve portability with sed -i (in-place editing)?

αғsнιη
  • 41,407