我想,以取代#Banner none
与Banner /etc/sshd_banner
该距离/etc/sshd_config
.如果我跑
sudo sed -i "s/#Banner none/Banner \/etc\/sshd_banner" /etc/sshd_config
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
sed:1:"/ etc/sshd_config":未终止的替代模式
有关如何解决此问题的任何想法?
Jot*_*tne 30
试试这个:
sudo sed -i "" "s|#Banner none|Banner /etc/sshd_banner|" /etc/sshd_config
Run Code Online (Sandbox Code Playgroud)
通过更改分隔符,您无需逃避 "
您的原始帖子最后错过了一个/
.
从OS X手册
-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.
Run Code Online (Sandbox Code Playgroud)
/
= zero-length
jub*_*0bs 28
你的命令有三个问题:
/
./
无论如何都不能使用分隔符,因为此字符出现在您尝试替换/替换的字符串中.您应该使用不同的字符(如竖线字符)作为分隔符.sed
Mac OS X附带的版本(BSD)中,该-i
标志需要一个强制 <extension>
参数,您的命令缺失.如果要使用此版本的原位编辑文件,则空字符串(""
)应该跟随该-i
标志sed
.总之,试试
sudo sed -i "" "s|#Banner none|Banner /etc/sshd_banner|" /etc/sshd_config
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
28277 次 |
最近记录: |