【发布时间】:2018-03-14 20:39:52
【问题描述】:
我是sed 的新手,想在httpd.conf 文件中进行修改。
这是要搜索的文本
<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.2/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 --- Want to change this to AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
任务:我的任务是将AllowOverride None改为AllowOverride All。
sed 'N;s:<Directory "/var/www/html">\(.*\)AllowOverride None\(.*\): <Directory "/var/www/html">\1AllowOverride All\2:' /etc/httpd/conf/httpd.conf > newHttpdConf.ini
正则表达式解释
开头:< Directory "/var/www/html">
在 AllowOverride None 之前存储任何内容:\(.*\)
寻找:AllowOverride None
之后存储任何东西:\(.*\)
当我在 sed command 上运行时,我没有看到任何替换。 我犯了什么错误。
谢谢
【问题讨论】: