What is wrong with my string substitution using sed on Mac OS X?
macos, sed
Solution
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` = `""`
Problem
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?