我要替换#End wp conf
和#Start wp conf
<Directory "/home/user/public_html/">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
</Directory>
#End wp conf
之间的所有内容:
sed -i -e "s/#Start wp conf.*#End wp conf//g" /root/test-conf
我尝试了sed -i -e "s/\(#Start wp conf\).*\(#End wp conf\)//g" /root/test-conf
,但是它没有替代任何东西。
我也尝试过<textarea>
答案 0 :(得分:2)
使用sed
,您可以这样做:
sed '/#Start wp conf/,/#End wp conf/d' file