perl -ne '/pattern/?$t=1&&print:{($t)?$t++:""}&&($t&&$t<12)?print:""' filename