Background
We are moving from managing hosts by hand to configuration management.
20 files
I want to compare 20 times a config file from 20 hosts. For example
/etc/crontab
Use case
I guess about 15 of 20 files are identical. I want to see the five files which where modified with “vi” by hand.
I want an overview, no automated action like patching …
How to compare them …?
I tried my favorit diff tool (meld), but it does not allow more than three files 🙁
Answer
I try to wrap my head around what diffing 20 files to each other would accomplish, but maybe I have another approach.
I assume that you want to know what kind of cron jobs are defined over all of your systems. Instead of diffing the files, I propose to output them together, sort
the output and then use uniq
to omit duplicate lines:
File1:
10 10 * * * /myjob.sh
* * * * * /everyminute.sh
File2:
20 20 * * * /evening-job.sh
* * * * * /everyminute.sh
All jobs over all files:
cat File1 File2 | sort | uniq -c
1 10 10 * * * /myjob.sh
1 20 20 * * * /evening-job.sh
2 * * * * * /everyminute.sh
The first column shows the numer of times this job was defined.
Attribution
Source : Link , Question Author : guettli , Answer Author : Sven