Linux – sed, replace in linux http://cdn1 with https://cdn1

linuxsed

I want to replace http://cdn1.domain.com with https://cdn1.domain.com in 200 .html files and I don't know how to do that with sed.

Can somebody help me with this?

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

Best Answer

If they are in same directory, you can just do this:

sed -i 's|http://cdn1.domain.com|https://cdn1.domain.com|g' *.html

If not, run find:

find . -name "*.html" -exec sed -i 's|http://cdn1.domain.com|https://cdn1.domain.com|g' {} \;
Related Topic