OT: sed/awk pointers needed

Lawrence Velázquez larryv at macports.org
Tue Sep 30 18:52:40 PDT 2014


On Sep 30, 2014, at 4:02 PM, Craig Treleaven <ctreleaven at macports.org> wrote:

> you've given me a complete solution!

I just realized that you're probably using "N" to signify that a variant is not selected, so "Y" should be used if a variant *is* selected.


# 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


vq


More information about the macports-dev mailing list