Setconf



What is it?

Setconf is a small utility that can be used for changing settings in configuration textfiles.

What can it do?

If there's a textfile with fields like these:
    CC=abc
    lights := on
    compile_today: true

Setconf can change the values to something else. It will take the first key it finds and change the value.

Setconf can also change values that span over multiple lines, by adding an end string as the last parameter. A typical end string would be ')' or ']'.

Example

You are writing a PKGBUILD for Arch and wish to change a setting without using sed.
Let's say you want to change CC from abc to gcc and that "CC=gcc make" doesn't cut it, for some reason.

Then you can use the following command:

setconf Makefile CC gcc

Why?
Syntax comparison

sed -i filename 's/key=oldvalue/key=value/g'

vs.

setconf filename key value

Which arguments are supported?

Setconf ordinarily takes a filename, key and a new value for that key.
One can also give an optional end string, for replacing multiline values.
It's also possible to add lines with -a or --add.

See the man page or --help output for more information.

Source code and bug tracker

The source and issue tracker is available at github.

git clone git://github.com/xyproto/setconf.git

Installation

There are several options:
Alexander Rødseth 2013