Reputation: 2210
I'm trying to insert some lines into a directive in the Apache conf file, so that this is the final output:
<Directory />
Order deny,allow
Deny from all
Options None
AllowOverride None
</Directory>
I tried just to verify that it works:
http_file=/etc/httpd/conf/httpd.conf
sed -n "<Directory /> a\Deny from all" $http_file
But it gives this error: sed: -e expression #1, char 1: unknown command: '<'
.
So I escaped the special characters and tried this:
sed -n "/\<Directory \/\>/ a\Deny from all" $http_file
But it still doesn't work.
What am I missing?
Upvotes: 1
Views: 185
Reputation: 786091
Use this sed:
sed -n '/<Directory *\/>/ a\
Deny from all' "$http_file"
Upvotes: 1