# Search for new (*) or updated (&) jokes BEGIN { border=\ "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" c0=0 ; c1=0 ; new=0 } # introduction /^Version/ && (!starter) { starter=1 ; selecting=0; printf("NEW OR CHANGED SCIENCE JOKES\n");} # new subsection /^=[0-9]+\.[0-9]+ / && !/[a-z]/ { c1=0 ; subtitle=$0 ; next } # new section /^=[0-9]+\. / && !/[a-z]/ { c0=0 ; c1=1; title=$0 ; next } # next joke - unselect /^[*&MBPCEA]*______________________+$/ { new=0 } # end section = end joke /^\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\++$/ {new=0 ; selecting=1} /^[*&][MBPCEA]*______________________+$/ { new=1; if(c0==0) { print border print title c0=1 } if(c1==0) { print border print subtitle c1=1 } } # print line of new joke new==1 { print $0 } # print introduction !selecting { print $0 }