sedはhttpd.conf行を削除します

sedはhttpd.conf行を削除します

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

しかし、成功しませんでした。

ベストアンサー1

<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

おすすめ記事