Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to replace #Banner none with Banner /etc/sshd_banner that is within /etc/sshd_config. If I run

sudo sed -i "s/#Banner none/Banner /etc/sshd_banner" /etc/sshd_config

I get the following error

sed: 1: "/etc/sshd_config": unterminated substitute pattern

Any ideas on how to fix this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

Three problems with your command:

  1. You're missing the terminating /.
  2. You can't use / as delimiter anyway, because this character occurs in the string you're trying to replace/substitute. You should use a different character, such as a pipe character, as delimiter.
  3. In the version (BSD) of sed that ships with Mac OS X, the -i flag expects a mandatory <extension> argument, which your command is missing. An empty string ("") should follow the -i flag if you want to edit the file in-place with this version of sed.

In summary, try

sudo sed -i "" "s|#Banner none|Banner /etc/sshd_banner|" /etc/sshd_config

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...