Skip to content

Instantly share code, notes, and snippets.

@johnccfm
Last active August 29, 2015 14:16
Show Gist options
  • Save johnccfm/d417ea127b8977136421 to your computer and use it in GitHub Desktop.
Save johnccfm/d417ea127b8977136421 to your computer and use it in GitHub Desktop.
Compare and diff mysql config files
#!/bin/bash
extract-keys() {
<$1 sed 's/#.*//;s/[[:space:]]\+//;/^$/d;/^!/d' |
gawk -F= '!/^\[/ { print pref "." $1 "\t" $2 } match($0, /\[([^\]]*)\]/, m) { pref = m[1] }' |
sort
}
(printf "Key %s %s\n--- --- ---\n" $1 $2
join -a1 -a2 -o 0,1.2,2.2 -e. <(extract-keys $1) <(extract-keys $2) | awk '$2 != $3') | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment