comm needs the input files to be sorted.
After composing a post, I checked what trac was and looked in the configuration section of the documentation. The config
file is in the form used by Apache and Windows 3.1 .ini files.
[section]
config entry
config entry
[section 2]
config entry
config entry
How many configuration files do you need to setup?
IMHO, it may be better to manually go through which configuration entries are global by the nature of what they are. Then create a template config file to use to configure each machine with items not in the config file.
Here is an fragment of the wine.ini from picasa:
Code:
[Strings]
MciExtStr="Software\Microsoft\Windows NT\CurrentVersion\MCI Extensions"
Mci32Str="Software\Microsoft\Windows NT\CurrentVersion\MCI32"
Desktop="Control Panel\Desktop"
Metrics="Control Panel\Desktop\WindowMetrics"
CurrentVersion="Software\Microsoft\Windows\CurrentVersion"
CurrentVersionNT="Software\Microsoft\Windows NT\CurrentVersion"
FontSubStr="Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes"
Control="System\CurrentControlSet\Control"
[Classes]
HKCR,.avi,"Content Type",2,"video/avi"
HKCR,.dll,"Content Type",2,"application/x-msdownload"
HKCR,.exe,,2,"exefile"
HKCR,.exe,"Content Type",2,"application/x-msdownload"
HKCR,.htm,,2,"htmlfile"
HKCR,.htm,"Content Type",2,"text/html"
HKCR,.html,,2,"htmlfile"
You could do something like:
sed '/[Strings]/,/^$/{ /[Strings]/!p }' *.ini >strings.merged
This will cut out all of the values from the strings sections.
Next you could do something like:
grep -c 'MciExtStr="Software\Microsoft\Windows NT\CurrentVersion\MCI Extensions"' strings.merged
This will return the number of matches.
grep -c 'MciExtStr="Software\Microsoft\Windows NT\CurrentVersion\MCI Extensions"' configfiles/*.ini
will return the same thing without cutting out the [strings] section. A name="value" pair would have to be
unique to a section to avoid a miscount.
If the number of matches equals the number of config files, then that entry can go into a global config file.
---
It may be better to read all of the files in a pearl script. You could have the "name" part as the index to a hash.
Read in a single file to store the values, and have another field or array so you can track whether the items are unique or not. Initialize the unique field to "yes" on the first config file.
Next read in the other config files and whenever a value differs, change the unique field from "yes" to "no".
Finally use the hash array to print out only the unique items.