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?
Three problems with your command:
/
./
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.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
Use another delimiter
Eks here I do use "
as delimiter
sudo sed -i "" "s|#Banner none|Banner /etc/sshd_banner|" /etc/sshd_config
By changing the delimiter, you do not need to escape the /
Your original post missed one /
at the end.
From OS X manual
-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension
is given, no backup will be saved. It is not recommended to give a zero-length extension when
in-place editing files, as you risk corruption or partial content in situations where disk
space is exhausted, etc.
zero-length
= ""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With