I am follow the example of using sed
So, for me, specifically, I am trying to insert the following:
<Location "someplace">
AuthBasicProvider ldap
AuthType Basic
AuthName "Auth"
AuthLDAPURL someurl
AuthzLDAPAuthoritative on
AuthLDAPBindDN someuser
AuthLDAPBindPassword somepassword
</Location>
</VirtualHost>
sed -n 'H;${x;s/\<\/VirtualHost> .*\n/test string &/;p;}' vhost.conf
</VirtualHost>
This works in GNU Sed:
sed -i -n 'H;${x;s/<\/VirtualHost>.*/ test string\n&/;p;}' vhost.conf
For OSX/BSD:
sed -i '' -n 'H;${x;s/<\/VirtualHost>.*/ test string\'$'\n''&/;p;}' vhost.conf