Search code examples
bashredhat

Adding new line to config file using bash script


is there a way to append a new line after a specific line in a config file using bash script?

For example, i want to insert a new line "Protocol 2" after "The default requires explicit activation of protocol 1" line using bash script. I would appreciate it greatly if any help is given. Thank you.

sshd_conf


Solution

  • Try this:

    sed -i /etc/ssh/sshd_config -e '/# The default requires explicit activation of protocol 1/a Protocol 2'
    

    (Please post text files as text, not as images.)