Replace string which contains asterisk with sed [duplicate]
This question already has answers here: Sed replace asterisk symbols (5 answers) Closed 15 hours ago. 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 […]
Replace string which contains asterisk with sed [duplicate]
This question already has answers here: Sed replace asterisk symbols (5 answers) Closed 15 hours ago. 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 […]
Replace string which contains asterisk with sed [duplicate]
This question already has answers here: Sed replace asterisk symbols (5 answers) Closed 15 hours ago. 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 […]
Replace string which contains asterisk with sed [duplicate]
This question already has answers here: Sed replace asterisk symbols (5 answers) Closed 15 hours ago. 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 […]
Replace string which contains asterisk with sed [duplicate]
This question already has answers here: Sed replace asterisk symbols (5 answers) Closed 15 hours ago. 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 […]
Replace string which contains asterisk with sed [duplicate]
This question already has answers here: Sed replace asterisk symbols (5 answers) Closed 15 hours ago. 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 […]
Why isn’t sed matching a space with the s character class? [duplicate]
This question already has answers here: sed (in bash) works with [ t] but not with s? (2 answers) Closed 19 mins ago. I’m writing a script to update some config files. One of the config file lines looks like this: hosts: [localhost] I’m using to do the substitutions which is working fine, but that […]
Half of a string using regex
I’m looking to capture groups of equal size, but there’s more than just one unary character in my string (eg the usual (.*)1
trick doesn’t work because the second half is different from the first)
Is it possible to escape regex metacharacters reliably with sed
I’m wondering whether it is possible to write a 100% reliable sed
command to escape any regex metacharacters in an input string so that it can be used in a subsequent sed command. Like this:
To match a digit inside a negated set
I need to match an arbitrary digit inside a negated set, but becasue sed
doesn’t support d
, I’m not sure how to do it.