sed替换字符串中的某些字符

test.txt原文内容
http://jsldfjaslfjsldfjasl/test?jlsdfjsalfjslfd
使用sed替换
sed -ri 's/(http://)[^/]*(/test)/1localhost:88882/' test.txt

test.txt替换后内容
http://localhost:8888/test?jlsdfjsalfjslfd

原文地址:https://www.cnblogs.com/vickey-wu/p/9089317.html