Orphaned Response
ajs
ajs at hpfcla.UUCP
Sun May 12 05:43:00 AEST 1985
Re: big calendar printer
Just for grins, here's something similar, but it's a shell script which
uses cal(1) and awk(1) to do the job. I call it "calbig".
# Script to produce big (page sized) calendars from cal(1) output.
# Input data looks like this (for example):
#
# November 1983
# S M Tu W Th F S
# 1 2 3 4 5
# 6 7 8 9 10 11 12
# 13 14 15 16 17 18 19
# 20 21 22 23 24 25 26
# 27 28 29 30 note: this line may be short.
# Check arguments:
case $# in
0) months=`date +%m` # default to current.
year=19`date +%y`
;;
1) months="1 2 3 4 5 6 7 8 9 10 11 12" # whole year.
year="$1"
;;
2) months="$1" # one month.
year="$2"
;;
*) echo "usage: $0 [[month(s)] year]" >&2 # error.
exit 1
esac
# Print calendars:
for month in $months
do
cal $month $year |
awk '
BEGIN { days = \
" Sunday Monday Tuesday Wednesday Thursday Friday Saturday "
top = \
" _________ _________ _________ _________ _________ _________ _________ "
bar = \
"|_________|_________|_________|_________|_________|_________|_________|"
cols = \
"| | | | | | | |"
}
/S M Tu W Th F S/ { # start of month header.
printf ("%s\n%s\n", days, top);
next;
}
/[a-z]/ { # a month title.
printf ("\n\n\n\t\t\t%s %s\n\n\n", $1, $2);
next;
}
/[0-9]/ { # a number line.
line = $0 " "; # pad it.
for (col = 1; col < 20; col += 3)
printf ("| %2s ", substr (line, col, 2));
printf ("|\n");
for (row = 2; row < 8; row++)
print cols;
print bar;
}
' |
sed "s/^/ /" # indent one tab.
echo "\f\c" # end page.
done
More information about the Comp.sources.unix
mailing list