https://github.com/comcast/compare-ini-files
Compare an arbitrary number of .ini files based on logical sections and key/value pairs.
https://github.com/comcast/compare-ini-files
Last synced: about 1 year ago
JSON representation
Compare an arbitrary number of .ini files based on logical sections and key/value pairs.
- Host: GitHub
- URL: https://github.com/comcast/compare-ini-files
- Owner: Comcast
- License: apache-2.0
- Created: 2016-09-16T14:49:45.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2021-02-04T22:48:19.000Z (over 5 years ago)
- Last Synced: 2025-04-11T21:07:11.037Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 10
- Watchers: 11
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Compare Ini Files
The problem: You have multiple copies of an "ini" file (https://en.wikipedia.org/wiki/INI_file)
in use by an app (possibly an app deployed in multiple datacenters...), and you want to compare them/diff them. Or worse yet: the stanzas and key-value pairs are in different orders in each file, and sorting through them would be a manual process that takes hours and is prone to error.
Solution: This script. The syntax is simple:
```
compare-ini-files filename1 filename2 [filename3 [filename4 [... ] ] ]
```
After loading the contents of the specified files into memory, this script
then checks to make sure all stanzas exist in each file, then does a key-by-key
comparison on each stanza, and reports any differences between the files.
## Installation
```
brew tap comcast/opensource https://github.com/Comcast/homebrew-opensource.git
brew install compare-ini-files
```
## Testing out the script
Clone this repo, and run `./compare-ini-files test/*` on the command line.
The output should resemble this:
```
#
# Starting config file audit of the following files:
#
# test/file1.conf
# test/file2.conf
# test/file3.conf
#
#
# Loading files...
#
#
# Comparing contents...
#
File: 'test/file3.conf' is missing the following stanzas:
[this stanza is found in file 1 and 2]
Stanza: [common in all files]
Key: 'specific to file3' found with multiple values:
Value 'somevalue' found in files:
test/file3.conf
These files did NOT contain the key:
test/file1.conf
test/file2.conf
```
## Requirements
- A relatively recent version of PHP should be installed.
- Read access to the files in question
## Development
Development can be done in Docker:
`docker build -t compare-ini-files . && docker run -it -v $(pwd):/mnt compare-ini-files test/*`
That command builds an image locally and runs the `compare-ini-files` script inside of a
Docker container.
Douglas Muth
Bugs can be filed here or emailed directly to me.