Skip to content

Instantly share code, notes, and snippets.

@larryv
Last active August 29, 2015 14:07
Show Gist options
  • Save larryv/daa6fffd5296b3ff2b94 to your computer and use it in GitHub Desktop.
Save larryv/daa6fffd5296b3ff2b94 to your computer and use it in GitHub Desktop.
# Save port to hold space.
/ has the variants/ {
s/ has .*$//
h
d
}
# Remove noise.
/conflicts with/d
/^[^:]*mariadb[^:]*:/b db_variant
/^[^:]*mysql[^:]*:/b db_variant
/^[^:]*percona[^:]*:/b db_variant
d
:db_variant
# Append desired suffix to variant name.
/^\[+\]/s/.*]\(.*\):.*$/\1 Default/
/^[[:blank:]]*+/s/[[:blank:]]*+\(.*\):.*$/\1 Y/
/^[[:blank:]]*[^+]/s/[[:blank:]]*\(.*\):.*$/\1 N/
# Extract port name from hold space and append variant name and suffix.
x
s/[[:blank:]].*$//
G
s/\n/ /
# Print pattern space and save to hold space for subsequent lines.
p
h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment