#!/bin/bash # dayinpast - given a date, report what day of the week it was if test $Argc -ne 3 { echo "Usage: $[basename $0] mon day year" > !2 echo " with just numerical values (ex: 7 7 1776)" > !2 exit 1 } date --version > /dev/null !2 > !1 # discard error, if any setglobal baddate = "$Status" # just look at return code if test ! $baddate { date -d $1/$2/$3 +"That was a %A." } else { if test $2 -lt 10 { setglobal pattern = "" $2[^0-9]"" } else { setglobal pattern = ""$2[^0-9]"" } setglobal dayofweek = $[ncal $1 $3 | grep $pattern | cut -c1-2] match $dayofweek { with Su echo "That was a Sunday"; with Mo echo "That was a Monday"; with Tu echo "That was a Tuesday"; with We echo "That was a Wednesday"; with Th echo "That was a Thursday"; with Fr echo "That was a Friday"; with Sa echo "That was a Saturday"; } } exit 0