Click to See Complete Forum and Search --> : cal output


ArtVandelay
01-22-2005, 03:05 PM
Hi everyone.

I noticed the command
cal -3
would show the previous, current, and next month.

I was hoping to pipe it into awk so I could
easily add abit of additional formatting to
that output, but unfortunately, this output
shows the three months horizontally instead
of vertically.

This makes awk's $1, $2, $3, etc. variables
do wild, crazy things.

Before I go on some big coding quest, I thought
I may as well ask if there's an easy way to
get the three months outputted vertically
instead.

The horizontal format doesn't lend itself to
additional processing at all. It just kind of
"looks nice".

ArtVandelay
01-22-2005, 05:43 PM
for everyone else's benefit, here's how I did it:


cal `date +%m -d -1month` `date +%Y -d -1month`; \
cal; \
cal `date +%m -d +1month` `date +%Y -d +1month`



cal and date's man pages left a little something to be
desired but googling:


unix command "date -d" "next month"


Finally brought up something relevant. date and cal are
not easy to google on.
:)