views:

34

answers:

2

Hi,

I need a tool that allows me to parse a config file and request some data from it.

The format of the config file is free (it can be INI, XML, and so on) but the more human-friendly, the better.

Here is a sample config file (using XML, but it could be anything: i don't mind the format):

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
  <name>Some name</name>
  <description>Some description</description>
</configuration>

The tool usage should be something like:

[ereOn@server ~]$ the_tool config.xml "string(/configuration/name)"
Some name
[ereOn@server ~]$ the_tool config.xml "string(/configuration/description)"
Some description

Do you know any Linux tool that can do that ?

+2  A: 

You could do that with python (.ini-Style config files): http://docs.python.org/library/configparser.html

EDIT: You could just use sed with regexes, too (but forget the "easily" then, if you're not experienced a bit with sed :P).

joni
+2  A: 

Perl has modules for many different formats of config file including JSON and INI

David Dorward