sed,在 linux 中将 http://cdn1 替换为 https://cdn1

And*_*iG. 10 linux sed

我想http://cdn1.domain.comhttps://cdn1.domain.com200 个 .html 文件替换,但我不知道如何用 sed 做到这一点。

有人可以帮我解决这个问题吗?

sed -i '/http:/\/\cdn1/http:/\/\cdn1/' cum-comand.html
sed: -e expression #1, char 8: unknown command: `\'

sed -i '/http:\/\/cdn1/http:\/\/cdn1/' cum-comand.html
sed: -e expression #1, char 17: extra characters after command
Run Code Online (Sandbox Code Playgroud)

Jak*_*sic 24

如果它们在同一目录中,您可以这样做:

sed -i 's|http://cdn1.domain.com|https://cdn1.domain.com|g' *.html
Run Code Online (Sandbox Code Playgroud)

如果没有,请运行查找:

find . -name "*.html" -exec sed -i 's|http://cdn1.domain.com|https://cdn1.domain.com|g' {} \;
Run Code Online (Sandbox Code Playgroud)