I have a httpd.conf file containing the following virtual hosts : <VirtualHost *:443>JkMount /soncn/* tomcat3SSLProtocol -all +TLSv1SSLCipherSuite RSA:!LOW:!EXP:!eNULL:!aNULL:!RC4SSLEngine onSSLCertificateFile blaSSLCertificateKeyFile  blaRewriteEngine OnRewriteOptions InheritServerName dionisos</VirtualHost>SSLSessionCache  dbm:/opt/apache/logs/ssl_gcache_data<VirtualHost *:8443>SSLProtocol -all +TLSv1SSLCipherSuite RSA:!LOW:!EXP:!eNULL:!aNULL:!RC4SSLEngine on SSLCertificateFile blaSSLCertificateKeyFile  blaRewriteEngine OnRewriteOptions InheritServerName dionisosProxyRequests OffProxyPreserveHost OnPerlModule CSA_Filter<Proxy *>Require all granted</Proxy>ProxyPass / ajp://162.237.187.150:8012/ProxyPassReverse / ajp://162.237.185.150:8012/ProxyTimeout 3600</VirtualHost><VirtualHost *:8191>SSLProtocol -all +TLSv1SSLCipherSuite RSA:!LOW:!EXP:!eNULL:!aNULL:!RC4SSLEngine onSSLCertificateFile blaSSLCertificateKeyFile  blaRewriteEngine OnRewriteOptions InheritServerName dionisosProxyRequests OffProxyPreserveHost OnPerlModule CSA_Filter<Proxy *>Require all granted</Proxy>ProxyPass / ajp://bla:8010/ProxyPassReverse / ajp://bla:8010/ProxyTimeout 3600</VirtualHost>I want to insert the following lines only for VirtualHost *:443 : <Proxy *>Require all granted</Proxy>ProxyPass /App https://servername:8080/App/ProxyPassReverse /App https://servername:8080/App/I had a lot of tries but could not find the proper sed :cat httpd.conf|tr '\n' '^'|sed 's#\(<VirtualHost \*:443>.*ServerName dionisos\)#\1 \n<Proxy *>\nRequire all granted\n</Proxy>\nProxyPass /App https://servername:8080/App/\nProxyPassReverse /Wibox https://servername:8080/App/ \n#g'|tr '^' '\n' > httpd.conf.updated
Sed in httpd.conf only for only one 
linux;sed;apache httpd
With GNU sed and GNU bash:Put new lines in a file (insert.txt).sed '/^<VirtualHost \*:443>/r insert.txt' httpd.confor use stdin:echo -e 'lines\nto\ninsert' | sed '/^<VirtualHost \*:443>/r /dev/stdin' httpd.confIf you want to edit your httpd.conf in place use sed's option -i.