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

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


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

  

posted @ 2019-01-09 16:56  lixinliang  阅读(335)  评论(0编辑  收藏  举报