shell sed 替换
#DocumentRoot /var/www
DocumentRoot /home/cxl/web
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
#<Directory /var/www/>
<Directory /home/cxl/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
以上一段代码,想将“<Directory /var/www/>”后面内容的“AllowOverride None”替换为“AllowOverride All”,仅替换这一个,别的不变
用shell脚本怎么写?
[解决办法]
sed '/<Directory \/var\/www\/>/,/AllowOverride None/s/AllowOverride None/AllowOverride All/' text