Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 want to update

<MySettingsSettings enabled="false" logFilePath="E:\server.log" />


<MySettingsSettings enabled="true" logFilePath="D:\server.log" />

How can I do this through sed? or is there any other way to update in a windows server?

share|improve this question
Ah, fun! Editing xml/html with regular expressions. Madness may be in your future. (…) – Zoredache Feb 18 '10 at 2:13

My suggestion, is that you use a real programming language that can actually parse and update XML/HTML documents properly. Using sed to update XML/HTML will probably fail in the long run.

share|improve this answer
+1 : Didn't notice this was a XML file. – Studer Feb 18 '10 at 2:25
I am just assuming it is xml/html. But it sure looks like it. – Zoredache Feb 18 '10 at 2:37

A simple substitution from your example can be done like this:

sed -e 's/enabled="true"/enabled="false"/g' -e 's/logFilePath="D:/logFilePath="C:/g' myfile.xml

However, I would agree with Zoredache's warning that unless you are only doing a very simple string replacement inside XML, you'd be better off with a language that has libraries available specifically built for parsing XML.

A great resource for a multitude of handy sed commands is the "sed one-liner" file:

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.