9

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
4
  • 1
    What have you tried so far? Please edit your question and include what you've tried and why it didn't work. – EEAA Sep 2 '14 at 23:04
  • 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 – AndreiG. Sep 2 '14 at 23:05
  • You have reversed your slashes and backslashes. – Michael Hampton Jan 20 '17 at 1:13
22

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' {} \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.