Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Linux Red Hat 5 Enterprise version. When using vi to replace string, we normally use the following command in vi -- "s/original_word/replaced_word/g", my question is, if original_word or replaced_word contains "/", how to replace?

For example, I want to replace /goo/foo/zoo to /1/2/3.

thanks in advance!

share|improve this question
up vote 3 down vote accepted
  1. you can use a different separator, eg : or , or ; or | or whatever you like
  2. escape the separator if the separator is part of the search string, meaning: put a \ before the separator, like this s/goo\/foo\/zoo/1\/2\/3/g
share|improve this answer
Thanks, question answered! – George2 Jul 28 '10 at 12:47

Either use a different character for the command delimiter, or escape the slashes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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