0

This question already has an answer here:

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

marked as duplicate by Isaac, αғsнιη, muru, Kusalananda sed Sep 30 '18 at 7:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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 or ask your own question.