skip to Main Content

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.

2

Answers


  1. What you’re using is not matching what you believe. In regular expressions * has special meaning.

    Login or Signup to reply.
  2. 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 [*].


    See: The Stack Overflow Regular Expressions FAQ

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search