![sed,在 Linux 中将 http://cdn1 替换为 https://cdn1](https://linux22.com/image/640902/sed%EF%BC%8C%E5%9C%A8%20Linux%20%E4%B8%AD%E5%B0%86%20http%3A%2F%2Fcdn1%20%E6%9B%BF%E6%8D%A2%E4%B8%BA%20https%3A%2F%2Fcdn1.png)
我想替换http://cdn1.domain.com
200https://cdn1.domain.com
个 .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
答案1
如果它们在同一个目录中,您可以这样做:
sed -i 's|http://cdn1.domain.com|https://cdn1.domain.com|g' *.html
如果没有,运行查找:
find . -name "*.html" -exec sed -i 's|http://cdn1.domain.com|https://cdn1.domain.com|g' {} \;