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

1 Answer 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)?

Not the answer you're looking for? Browse other questions tagged .