futriix/utils/compare_config.sh
benschermel 5a1a712ec6 add script to compare all active config parameters of any 2 config files
Former-commit-id: 89beaf2460e969c3ee18e03fe539de5833dba50a
2021-08-10 20:10:28 -04:00

41 lines
1.0 KiB
Bash

#! /bin/bash
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$#" -ne 2 ]] ; then
echo "This script is used to compare different KeyDB configuration files."
echo ""
echo " Usage: compare_config.sh [keydb1.conf] [keydb2.conf]"
echo ""
echo "Output: a side by side sorted list of all active parameters, followed by a summary of the differences."
exit 0
fi
conf_1=$(mktemp)
conf_2=$(mktemp)
echo "----------------------------------------------------"
echo "--- display all active parameters in config files---"
echo "----------------------------------------------------"
echo ""
echo "--- $1 ---" > $conf_1
echo "" >> $conf_1
grep -ve "^#" -ve "^$" $1 | sort >> $conf_1
echo "--- $2 ---" >> $conf_2
echo "" >> $conf_2
grep -ve "^#" -ve "^$" $2 | sort >> $conf_2
pr -T --merge $conf_1 $conf_2
echo ""
echo ""
echo "--------------------------------------------"
echo "--- display config file differences only ---"
echo "--------------------------------------------"
echo ""
sdiff --suppress-common-lines $conf_1 $conf_2
rm $conf_1
rm $conf_2
exit 0