Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My configuration file has the following format

[general]
setting1=true
setting2=value2

[ssl]
setting1=sadfsdf
setting2=sdfadsfkljasdf

How would I change setting 1's value to false? If I could just delete the line, I could use the response from another question I asked.

share|improve this question

1 Answer 1

try something like:

sed -i -r 's/setting1=true/setting1=false/' /path/to/your/file

or if you want to replace all instances of a setting try something like this:

sed -i -r 's/setting1=.*/setting1=false/' /path/to/your/file
share|improve this answer
    
I think you really should spend some time and learn a bit of regular expressions. sed makes a great deal of use on them... and you can easily answer your own questions if you spent 15 minutes learning regexp. –  TheCompWiz May 8 '12 at 21:06
    
Just to be sure you should match the start of line (unless your configuration variable names are prefix free): s/^setting1=.*/setting1=bar/ –  David Foerster Oct 15 '13 at 19:23

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.