sed 替换有单引号的行

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     #关键& 要转译

posted @ 2018-04-27 14:30  littlevigra  阅读(449)  评论(3编辑  收藏  举报