Skip to content

Instantly share code, notes, and snippets.

@sxd
Last active April 9, 2020 18:01
Show Gist options
  • Save sxd/cfaa201a615242efa66197636bb4c05a to your computer and use it in GitHub Desktop.
Save sxd/cfaa201a615242efa66197636bb4c05a to your computer and use it in GitHub Desktop.
FILE1=$1
FILE2=$2
if [[ -z "$FILE1" ]] || [[ -z "$FILE2" ]] ; then
echo "Must add two different config files"
exit 1
fi
compare() {
for LINE in `grep CONFIG $1 | sed 's/^#//g;s/^ //g;s/ is not set/=/g'`; do
CONFIG_NAME=$(echo $LINE | cut -f1 -d=);
CONFIG_VALUE=$(echo $LINE | cut -f2 -d=);
NEW=`grep $CONFIG_NAME"=" $2 | grep '=' | sed 's/\(.*\)=\(.*\)/\2/'`;
if [[ -z "$NEW" ]] && [[ -z "$CONFIG_VALUE" ]] ; then
continue;
fi
if [[ -z "$NEW" ]]; then
echo "Empty on "$2" "$LINE;
continue;
fi
if [ "$CONFIG_VALUE" != "$NEW" ]; then
echo "On "$1" "$LINE" ; new value on "$2" "$NEW;
fi
NEW="";
done
}
compare $FILE1 $FILE2 false
compare $FILE2 $FILE1 true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment