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

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

相关文章: