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

Usually when I need to replace some lines in a file, the first tool that comes to mind is sed -i:

sed -i 's|tool:.*|tool: some-tool|' 

However, it's inconvenient when there are . characters in the replacement string:

sed -i 's|host:.*|host: 127\.0\.0\.1|' 

Is there a better tool for this case?

share|improve this question
up vote 3 down vote accepted

. doesn't need to be escaped in the replacement, only in the regular expression.

share|improve this answer

Your Answer

 
discard

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.