cat test.txt
$config['useragent'] = 'Roundcube Webmail'; // Hide version number
//$config['username_domain'] = 'www.b.com'; #要去掉前面的//
$config['mime_types'] = '/etc/mime.types';
sed -i '///$config.*username_domain/ s&//&&g' test
文件中有这样一句置换对象
http://www.aaa.com/top.jsp?_para1=ture&_para2=false&_para3=ok
希望最后置换成
http://www.aaa.com/top/?_para1=ture&_para3=ok
sed -i '/http://www.aaa.com/ s#.jsp?_para1=ture&_para2=false&_para3=ok#/?_para1=ture&_para3=ok#' test.txt #关键& 要转译