TITLE="Penguin Guide to Jazz Diffs: 8th vs. 9th Editions" ED4COL="8th Ed." ED5COL="9th Ed." CROWN='' OP=0 CAVEAT="Note: These lists are [not] believed to be complete. The sort order has changed slightly between editions, so we use the more recent (9th Edition). Whole artist diffs are noted in red for drops, blue for adds." if [ "$1" = "-d" ]; then OP=1 TITLE="Penguin Guide to Jazz: Dropped from 9th Edition" ED5COL= LCMD='$3&&!$4' shift elif [ "$1" = "-a" ]; then OP=2 TITLE="Penguin Guide to Jazz: Added to 9th Edition" ED4COL= LCMD='!$3&&$4' shift elif [ "$1" = "-c" ]; then OP=3 TITLE="Penguin Guide to Jazz: Grade Changed in 9th Edition" LCMD='$3&&$4' shift elif [ "$1" = "-x" ]; then OP=4 TITLE="Penguin Guide to Jazz:
4-Star Records in 9th Edition" LCMD='$4~/^[*][*][*][*]/' shift elif [ "$1" = "-y" ]; then OP=5 TITLE="Penguin Guide to Jazz:
3.5-Star Records in 9th Edition" LCMD='$4~/^[*][*][*][(]?[*][)]?/' shift else LCMD='NF>0' fi IN=$1 OUT=$2 LINES=$(awk -F\| "$LCMD" $IN | wc -l) #echo "Lines: $LINES" awk -F\| 'BEGIN { file_n = 0 line_n = 400 line_c = 400 } function open_out() { fnm = sprintf("%s-%02d.php", FNAME, ++file_n) line_c = 0 printf("\n", \ TITLE, CAVEAT, ED4COL, ED5COL) >fnm if (!total_p) { total_p = int(LINES / line_n) + (LINES % line_n != 0) } } function close_out() { printf("


\n") >fnm printf("\n", FNAME, file_n, total_p, OP) >fnm } END { if (file_n) { close_out() } } /^#/ || NF==0 { next } { if (line_c >= line_n) { if (file_n) { close_out() } open_out() APrint = 0 } if ($1 != "") { AC = substr($1, 1, 1) if (AC == "-") { Artist = sprintf("%s", substr($1, 2)) } else if (AC == "+") { Artist = sprintf("%s", substr($1, 2)) } else { Artist = $1 } APrint = 0 } if (OP == 0 || (OP == 1 && $4 == "") || (OP == 2 && $3 == "") || (OP == 3 && $3 != "" && $4 != "") || (OP == 4 && $4 ~ /^[#]?[*][*][*][*]/) || (OP == 5 && $4 ~ /^[#]?[*][*][*][(]?[*][)]?/)) { printf("\n") >fnm if (APrint == 0) { printf("%s\n", Artist) >fnm APrint++ } else { printf(" \n") >fnm } if (NF >= 5 && $5) { Label = sprintf(" [%s]", $5) } else { Label = "" } printf("%s%s\n", $2=="" ? " " : $2, Label) >fnm if (OP != 2) { sub(/#/, CROWN, $3) printf("%s\n", $3=="" ? " " : $3) >fnm } if (OP != 1) { sub(/#/, CROWN, $4) printf("%s\n", $4=="" ? " " : $4) >fnm } printf("\n") >fnm line_c++ } }' OP=$OP CROWN="${CROWN}" FNAME=$OUT TITLE="${TITLE}" CAVEAT="${CAVEAT}" \ ED4COL="${ED4COL}" ED5COL="${ED5COL}" LINES="${LINES}" $IN