Search code examples
bashredhat

Editing a vi file using bash script


I am doing bash scripting in RHEL7. I managed to do some simple if-else scripting, however, I now need to edit /etc/ssh/sshd_config file using bash script. I have to remove the '#' at protocol 2. Is there any way to do this? In addition I would like to add the Protocol 2 line in if it does not exist. I would appreciate any help given.

ssh_config


Solution

  • @Michel O beat me with sed -i, but for more complex edits there is also ex, which gives you the power of vi from command lines.