【发布时间】:2016-02-12 00:28:01
【问题描述】:
我按照using sed to insert lines 的示例将其放入特定模式匹配位置的文件中。我已经在我的机器上运行了该问题的示例,它运行良好。
所以,对我来说,具体来说,我正在尝试插入以下内容:
<Location "someplace">
AuthBasicProvider ldap
AuthType Basic
AuthName "Auth"
AuthLDAPURL someurl
AuthzLDAPAuthoritative on
AuthLDAPBindDN someuser
AuthLDAPBindPassword somepassword
</Location>
我想将它插入到 .conf 文件 (this one to be exact) 的末尾,特别是在关闭 </VirtualHost> 之前。
但是,当我跑步时
sed -n 'H;${x;s/\<\/VirtualHost> .*\n/test string &/;p;}' vhost.conf
为了测试,文件的内容被打印出来但文件没有被改变。我是不是逃错了</VirtualHost> 或者我错过了什么?
(我也愿意接受其他将我的内容放入文件的解决方案。)
【问题讨论】: