You can do wonders with
awk when it comes to editing config files. However, if format is not line but section based, editing it becomes exercise in writing full blown programs and even a simple reading has potential to turn into a mess of regex nobody will understand in a year. It was on a day such as that I decided to make myself a command line INI file editor.
First, the most common action, reading value is as simple as giving section and key name:
$ inied --section mysqld --key key_buffer --print examples/my.cnf
Modifying a value is as easy:
$ inied --section mysqld --key key_buffer --edit 200M examples/my.cnf
From there on you can go crazy with pretty-printing, filtering, or even just piping it into any other tool.