#!/bin/ksh
YYYY1=`date +%Y`
YYYY2=${YYYY1} # Initial value - may change
YYYY3=${YYYY1} # Initial value - may change
MM1=`date +%m`
MM2=`expr ${MM1} - 1`
MM3=`expr ${MM1} + 1`
if [ "${MM2}" -lt 1 ]
then
MM2=12
YYYY2=`expr ${YYYY2} - 1`
fi
if [ "${MM3}" -gt 12 ]
then
MM3=1
YYYY3=`expr ${YYYY3} + 1`
fi
cal ${MM2} ${YYYY2} # Last month
cal ${MM1} ${YYYY1} # This month
cal ${MM3} ${YYYY3} # Next month
Hello,
I got this command cal -3, when doing google on the same.
NAME
cal - displays a calendar
SYNOPSIS
cal [-smjy13 ] [[ month ] year ]
DESCRIPTION
Cal displays a simple calendar. If arguments are not specified, the current month is displayed. The options are as follows:
-1 Display single month output. (This is the default.) -3 Display prev/current/next month output. -s Display Sunday as the first day of the week. (This is the default.) -m Display Monday as the first day of the week. -j Display Julian dates (days one-based, numbered from January 1). -y Display a calendar for the current year.