Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to update

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

to

<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
2  
Ah, fun! Editing xml/html with regular expressions. Madness may be in your future. (stackoverflow.com/questions/1732348/…) –  Zoredache Feb 18 '10 at 2:13
add comment

2 Answers

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
add comment

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:

http://sed.sourceforge.net/sed1line.txt

share|improve this answer
add comment

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.