Hi!
I am attempting to use sed to change a file. The contents are something like this:
I want to change the second PasswordAuthentication to no. However, I am having some issues. My sed command is changing both to no.
This is what I've tried
That changes both.
That changes both.
That changes neither.
I guess I'm getting a bit confused about word boundaries. Any ideas what I'm doing wrong and how to accomplish what I'm trying to accomplish?
Thanks!
**EDIT: I believe I found the solution.
that seems to change PasswordAuthentication and not #PasswordAuthentication.
I am attempting to use sed to change a file. The contents are something like this:
Code:
#PasswordAuthentication yes PasswordAuthentication yes
This is what I've tried
Code:
sed -i 's/\<PasswordAuthentication yes/PasswordAuthentication no/g' sshd_config
Code:
sed -i "s/\bPasswordAuthentication yes/PasswordAuthentication no/g" sshd_config
Code:
sed -i "s/\>PasswordAuthentication yes/PasswordAuthentication no/g" sshd_config
I guess I'm getting a bit confused about word boundaries. Any ideas what I'm doing wrong and how to accomplish what I'm trying to accomplish?
Thanks!
**EDIT: I believe I found the solution.
Code:
sed -i "s/^PasswordAuthentication yes*$/PasswordAuthentication no/g" sshd_config