Works with Gnu awk version 3.1.5 and with BusyBox v1.20.0.git awk To change the output width, change the value assigned to variable pagewide #!/bin/gawk -f BEGIN{ wkdays = "Su Mo Tu We Th Fr Sa" pagewide = 80 blank=" " for (i=1; i pagewide) { print center(line1) print center(line2) print center(line3) print center(line4) print center(line5) print center(line6) print center(line7) print center(line8) line1 = "" line2 = "" line3 = "" line4 = "" line5 = "" line6 = "" line7 = "" line8 = "" } } /q/{ exit } { monsize=substr(days,2*1,2) newdow=dow($1) print center("[ picture of Snoopy goes here ]") print center(sprintf("%d",$1) ) # January - December for (i=1; i<13; i++) { prmonth(i,newdow,monsize) newdow=(monsize+newdow) %7 if (newdow == 0) newdow = 7 monsize=substr(days,2+2*i,2) if (leap == 1 && monsize == 28) monsize = 29 } }