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(后)\增加的内容" 要修改的文件名称

  

上一篇:Confluence安装&破解&汉化


下一篇:SQL多表连接