Skip to content

Commit

Permalink
add script to compare all active config parameters of any 2 config files
Browse files Browse the repository at this point in the history
  • Loading branch information
benschermel committed Aug 11, 2021
1 parent 0c5d12b commit 89beaf2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions utils/compare_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#! /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

0 comments on commit 89beaf2

Please sign in to comment.