使用 bash 脚本向配置文件添加新行
Adding new line to config file using bash script
有没有办法使用 bash 脚本在配置文件中的特定行之后追加新行?
例如,我想使用 bash 脚本在 "The default requires explicit activation of protocol 1" 行之后插入新行 "Protocol 2"。如果提供任何帮助,我将不胜感激。谢谢你。
试试这个:
sed -i /etc/ssh/sshd_config -e '/# The default requires explicit activation of protocol 1/a Protocol 2'
(请 post 将文本文件作为文本,而不是图像。)
有没有办法使用 bash 脚本在配置文件中的特定行之后追加新行?
例如,我想使用 bash 脚本在 "The default requires explicit activation of protocol 1" 行之后插入新行 "Protocol 2"。如果提供任何帮助,我将不胜感激。谢谢你。
试试这个:
sed -i /etc/ssh/sshd_config -e '/# The default requires explicit activation of protocol 1/a Protocol 2'
(请 post 将文本文件作为文本,而不是图像。)