Last active
August 8, 2016 15:52
-
-
Save HokieGeek/bd6611d32a7860fa134e879fd408764a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID: 1 | |
NAME: Uno | |
ID: 2 | |
NAME: Dos | |
ID: 3 | |
NAME: Tres | |
ID: 4 | |
NAME: Cuatro | |
ID: 5 | |
NAME: Cinco | |
ID: 6 | |
NAME: Seis | |
ID: 7 | |
NAME: Siete | |
ID: 8 | |
NAME: Ocho | |
ID: 9 | |
NAME: Nueve | |
ID: 10 | |
NAME: Diez | |
ID: 11 | |
NAME: Once | |
ID: 12 | |
NAME: Doce | |
ID: 13 | |
NAME: Trece | |
ID: 14 | |
NAME: Catorce |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID: 14 | |
ID: 12 | |
ID: 10 | |
ID: 8 | |
ID: 6 | |
ID: 4 | |
ID: 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID: 5 | |
ID: 6 | |
ID: 7 | |
ID: 8 | |
ID: 9 | |
ID: 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID: 1 | |
ID: 2 | |
ID: 3 | |
ID: 4 | |
ID: 5 | |
ID: 6 | |
ID: 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { | |
if (ARGC < 2) { | |
print "USAGE: test.awk MTF [MTF.OVERRIDES...]" | |
exit 1 | |
} | |
} | |
FNR == 1 && NR > 1 { | |
overrides[override_cnt++]=gensub(/^.*\./, "", 1, FILENAME) | |
if (length(overrides[override_cnt-1]) > override_max) { | |
override_max=length(overrides[override_cnt-1]) | |
} | |
} | |
$1 == "ID:" { | |
id=$2 | |
if (FNR != NR) { | |
overrides[overrides[override_cnt-1]","id] | |
} | |
} | |
$1 == "NAME:" { | |
if (filter != "" && ($2 !~ filter && id !~ filter)) { next } | |
targets[id]=sprintf("%-7s (%02d)", $2, id) | |
} | |
END { | |
if (length(targets) > 0) { | |
# Setup for the header | |
overrides_fmt=sprintf(" %%-%ds", override_max) | |
for (j=override_max; j >= 0; j--) { | |
overrides_div=sprintf("%s=", overrides_div) | |
} | |
# Print the header | |
for (i=0; i < override_cnt; i++) { | |
header=sprintf("%s"overrides_fmt, header, overrides[i]) | |
divider=sprintf("%s%s", divider, overrides_div) | |
} | |
printf("%-12s %s\n=============%s\n", "Número", header, divider) | |
# Print the targets | |
for (id in targets) { | |
printf("%s ", targets[id]) | |
for (i=0; i < override_cnt; i++) { | |
printf(overrides_fmt, (overrides[i]","id in overrides) ? " " : "∙") | |
} | |
print "" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment