I have an HTML file on a Linux server that contains a long list of links. I am trying to edit this file as follows.

Find original occurrences of this type: http://www.test.org/name Replace them with: http://www.test.org/archive/name

How can I do this? I have tried running: sed -i -e 's/http://www.test.org/name/http://www.test.org/archive/name/g' user.html

However I get the following error back:

sed: couldn't open file ww.test.org/name/http://www.test.org/archive/name/g: No such file or directory

I am aware that there are questions that answer similar queries, but they have not been of help.


/ is default sed subexpression separator, use another one:

sed -i 's~http://www.test.org/name~http://www.test.org/archive/name~g' user.html
  • Much appreciated! – MadPhysicist Jul 14 '17 at 18:13
  • Sincere gratitude. Worked like a charm. – sg28 Jul 16 '20 at 22:21

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.