我有一个httpd配置文件,我想从其中删除整个块:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>从<Directory "/var/www/html">到关闭的</Directory>。
我试过:
sed '/-<Directory "\/var\/www\/html">/,/-<\/Directory>/d' /etc/httpd/conf/httpd.conf但没有成功。
发布于 2015-08-17 13:15:22
由于<Directory ...> (和</Directory>)语句之前的破折号,命令无法工作。这应该是可行的:
sed '/<Directory "\/var\/www\/html">/,/<\/Directory>/d' /etc/httpd/conf/httpd.conf另外,为了使它更易读,您可能需要使用另一个字符作为分隔符,例如,/,例如,#,如下所示;
sed '\#<Directory "/var/www/html">#,\#</Directory>#d' /etc/httpd/conf/httpd.conf发布于 2015-08-17 13:12:39
不需要-,因为您的文件在<Directory ...之前没有-。
试试这个:
sed '/<Directory "\/var\/www\/html">/,/<\/Directory>/d' filenamehttps://unix.stackexchange.com/questions/223690
复制相似问题