4

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.

1 Answer 1

7

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
2
  • 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, 2012 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/ Oct 15, 2013 at 19:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .