0
我是sed
的新手,並且想要對httpd.conf
文件進行修改。SED正則表達式錯誤
這裏是搜索
<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無:\(.*\)
查找:AllowOverride None
店東西后:\(.*\)
當我在sed命令上面運行時,我沒有看到任何替換。 我正在犯什麼錯誤。
感謝
不錯。我會試試這個。你能告訴我,我的正則表達式有什麼問題,我不會重複同樣的錯誤。 – voila
@voila東西是sed讀行是行和做模式匹配。因此,當它到達行 Directory/var/www/html>時,它不知道'AllowOverride'是否會出現在後面的行中。而'。*'只會選擇直到行尾而不是下一行 – nu11p01n73R
明白了..感謝您的幫助 – voila