apache中 sed 指定文件中某字符串增加行

#!/bin/bash
#在 servername 域名      字符串后面添加指定字符串
servername=`grep ServerName httpd-vhosts.conf |awk '{print $2}'`
for conf in $servername;do
  sed -i "/ServerName $conf/aErrorLog "logs/${conf}_error.log"" httpd-vhosts.conf
  sed -i "/ServerName $conf/aCustomLog "logs/${conf}_access.log" common" httpd-vhosts.conf
done


注: sed -i "/指定字符串/a(后)增加的内容" 要修改的文件名称

  

原文地址:https://www.cnblogs.com/lixinliang/p/10245460.html