I wanted to ask if there are any ready-made, free, or built-in bash tools or utilities for scripting manipulation of configuration file settings -- you know, the kind of file that is ubiquitous in Linux whereby "key = value" pairs are specified. Did a brief Google search and didn't readily find anything suitable. Maybe I didn't use the right search keywords. The files typically may contain comment lines, denoted by leading "#" characters, and there may be logical division of related groups by means of white space, neither of which I want to disturb or lose. So I'm thinking of a command-line utility which takes three arguments, say a command appearing something like inisetvalue filename keyname value for example it might be run with [berend at nova ~]$ sudo inisetvalue /etc/profile TMOUT 300 which searches in file "/etc/profile" for a key named "TMOUT" and sets the RHS value to "300". If the key is not found, then append that key-value pair to the file. I'm sure it's pretty easy to do with perl or even awk, but I'd be hard pressed to believe that no one else has already produced such a utility that handles the various permutations like for when existing key-value pairs may or may not have white space surrounding the "=" sign, or the key name possibly including white space, or the keyname appearing in a comment line or other context besides the value setting per se, etc. Regards, Berend Tober
More information about the ECLUG mailing list