首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >httpd.conf删除行

httpd.conf删除行
EN

Unix & Linux用户
提问于 2015-08-17 12:56:19
回答 2查看 858关注 0票数 3

我有一个httpd配置文件,我想从其中删除整个块:

代码语言:javascript
运行
复制
<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>

我试过:

代码语言:javascript
运行
复制
 sed '/-<Directory "\/var\/www\/html">/,/-<\/Directory>/d' /etc/httpd/conf/httpd.conf

但没有成功。

EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2015-08-17 13:15:22

由于<Directory ...> (和</Directory>)语句之前的破折号,命令无法工作。这应该是可行的:

代码语言:javascript
运行
复制
sed '/<Directory "\/var\/www\/html">/,/<\/Directory>/d' /etc/httpd/conf/httpd.conf

另外,为了使它更易读,您可能需要使用另一个字符作为分隔符,例如,/,例如,#,如下所示;

代码语言:javascript
运行
复制
sed '\#<Directory "/var/www/html">#,\#</Directory>#d' /etc/httpd/conf/httpd.conf
票数 8
EN

Unix & Linux用户

发布于 2015-08-17 13:12:39

不需要-,因为您的文件在<Directory ...之前没有-

试试这个:

代码语言:javascript
运行
复制
sed '/<Directory "\/var\/www\/html">/,/<\/Directory>/d' filename
票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/223690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档