Can someone recommend an easy way to get a value out of a "standard" config file without a lot of parsing?
Most config files I deal with are some variation of this format:
# This is a comment line
key1 = value1
key2 = value2
Or often without the equals sign.
; This is a comment line
I know I can open the file and parse out anything I need, but it's a lot of extra code. Just wondering if there is a unix utility or BASH command to do it. Something like:
getval -f /etc/myfile.conf -k key1
that will handle most types of config files and can find values and ignore comments.
If not, how about a couple of unix commands piped to each other? If it's anything that can be typed at the prompt, then I could execute it within perl and php scripts and capture the return value.
Naturally, it would also be great to have a one-liner that will update a value in a config file.