Skip to main content

sed - quickly serach and replace text in a file

The command sed is a very powerful command that can be use to add, delete, or modify text in an file.

Use the following to search and substitute text in a file:

sed 's/text-to-look-for/replacement-text/g' filename
#sed can take other delimiters as well, such as _ , #, or \

sudo sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config

image.png

image.png