Grant McWilliams

Tech Programming Bash Commandline Calender

Commandline Calender

An interesting commandline calender. If you don't supply an argument it will show you the output of cal (current month) but if you supply it a number 12 and lower it will show you that month in this year but if the number is 13 or above it will show you a calender of the year specified.

# Syntax acal

function acal {
case $# in
0) cal; return;;                #no arguments
1) m=$1; y=`date +%Y`;;         #1 argument
2) m=$1; y=$2;;                 #2 arguments

case $m in
Jan*|jan*      ) m=1;;
Feb*|feb*      ) m=2;;
Mar*|mar*      ) m=3;;
Apr*|apr*      ) m=4;;
May|may        ) m=5;;
Jun*|jun*      ) m=6;;
Jul*|jul*      ) m=7;;
Aug*|aug*      ) m=8;;
Sep*|sep*      ) m=9;;
Oct*|oct*      ) m=10;;
Nov*|nov*      ) m=11;;
Dec*|dec*      ) m=12;;
[1-9]|1[0-2] ) ;;         #numeric month
*     ) y=$m; m="";;
cal $m $y

acal $1
Tech Programming Bash Commandline Calender