0
votes

Trying to replace urls sitewide: "https://my.oldurl.com/directory" with new url "https:my.newurl.com"

What am I missing?

Tried:

find ./ -type f -exec sed -i 's/https:\/\/my.oldurl.com\/directory\//https:\/\/my.newurl.com//' {} \;

returned sed: -e expression #1, char 88:unknown option to `s'

sed -i 's#"https://my.oldurl.com/directory"#"https://mt.newurl.com"g'

returns sed: -e expression #1, char 85: unterminated `s' command

1

1 Answers

3
votes

Your first command:

-type f -exec sed -i 's/https:\/\/my.oldurl.com\/directory\//https:\/\/my.newurl.com//' {} \;

Has the wrong number of trailing /. Change it to either:

-type f -exec sed -i 's/https:\/\/my.oldurl.com\/directory\//https:\/\/my.newurl.com\//' {} \;

Or:

-type f -exec sed -i 's/https:\/\/my.oldurl.com\/directory\//https:\/\/my.newurl.com/' {} \;

Which one depends on whether you want the replacement string to be https://my.newurl.com or https://my.newurl.com/