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