#!/bin/sh # # bigcal - make a 78-column version of the output of the "cal" command # # Pass it the same arguments you'd pass to cal, if any. If you try a # full-year calendar, you probably won't get anything useful. # # Jef Poskanzer # Cal sends errors to stdout. Correct this. if [ `cal -h "$@" | wc -l` = 1 ] ; then cal -h "$@" >&2 exit 1 fi cal -h "$@" | head -n 1 | sed 's/^ *//' | awk '{printf "%s%s\n", substr(" ", length/2), $0}' cat << EOF +----------+----------+----------+----------+----------+----------+----------+ | Sunday | Monday | Tuesday |Wednesday | Thursday | Friday | Saturday | +----------+----------+----------+----------+----------+----------+----------+ EOF cal -h "$@" | tail -n +3 | egrep -v '^ *$' | sed -e 's/ *$//' -e '/^$/d' -e 's/ /x/g' -e 's/^/x/' | ( while read line ; do echo "$line" | sed -e 's/xxx/ /g' -e 's/x[0-9x][0-9]/| & /g' -e 's/$/|/' echo "$line" | sed -e 's/xxx/ /g' -e 's/x[0-9x][0-9]/| /g' -e 's/$/|/' echo "$line" | sed -e 's/xxx/ /g' -e 's/x[0-9x][0-9]/| /g' -e 's/$/|/' echo "$line" | sed -e 's/.../+----------/g' -e 's/$/+/' done ) | sed 's/x/ /g'