I'm trying to comment out a line via sed
command.
sudo sed -i "s|Include /etc/ssh/sshd_config.d/*.conf|#Include /etc/ssh/sshd_config.d/*.conf|" /etc/ssh/sshd_config
Why the command above does not work? What am I missing here? I get no errors, but the line is not commented out.
I'm doing that on a Debian 12 machine.
sed
uses regular expressions in its search term and asterisk (*
) is a special character (star quantifier) in this context. The star quantifier means that the preceding expression (here: /
) can match zero or more times.
To treat *
as a normal character replace it in your search term with \*
or [*]
.