#!/usr/bin/gawk -f /^\[[0-9]+a\] / { if(!n || (n % 27) == 0 || runon) { if ($0 ~ /
/) { output = 0; runon = 1; } else { output = 1; runon = 0; if(n) printf("\n"); print; } } else { output = 0; runon = 0; } n++; } /^\[[0-9]+[bcd]\] / { if(output) print; }