Issue
Require some help. Been trying to use sed to search for a block of text from httpd.conf and right after the search, use sed to add text at the block of text. This is an example.
sed -n '/<Directory "\/var\/www\/html">/,/<\/Directory>/p' httpd.conf
After that pipe this output to sed again to insert text right before the which will look like this:
<Directory "/var/www/html">
. . .
# Limit HTTP methods
<LimitExcept GET POST OPTIONS>
Require all denied
</LimitExcept>
</Directory>
However after trying alot of different ways still cant get what i want. Anyone can help ? hope this is not a duplicate issue. Thanks.
Solution
This might work for you (GNU sed);
sed -i -e '\#<Directory "/var/www/html"#,/<\/Directory>/{/<\/Directory>/i\INSERTED' -e '}' file
Use a range /first regexp/,/second regexp/command
and repeat the second regexp with a following insert command.
Answered By - potong Answer Checked By - Timothy Miller (WPSolving Admin)