#!/bin/bash # normdate--Normalizes month field in date specification # to three letters, first letter capitalized. A helper # function for Script #7, valid-date. Exits w/ zero if no error. proc monthNumToName { # Sets the variable 'month' to the appropriate value. match $1 { with 1 setglobal month = '"Jan'" with 2 setglobal month = '"Feb'" with 3 setglobal month = '"Mar'" with 4 setglobal month = '"Apr'" with 5 setglobal month = '"May'" with 6 setglobal month = '"Jun'" with 7 setglobal month = '"Jul'" with 8 setglobal month = '"Aug'" with 9 setglobal month = '"Sep'" with 10 setglobal month = '"Oct'" with 11 setglobal month = '"Nov'" with 12 setglobal month = '"Dec'" with * echo "$0: Unknown numeric month value $1" > !2; exit 1 } return 0 } # BEGIN MAIN SCRIPT–-DELETE BELOW THIS LINE IF YOU WANT TO # INCLUDE THIS IN OTHER SCRIPTS. # ================= # Input validation #if [ $# -ne 3 ] ; then # echo "Usage: $0 month day year" >&2 # echo "Typical input formats are 'August 3 1962' and '8 3 2002'" >&2 # exit 1 #fi #if [ $3 -le 99 ] ; then # echo "$0: expected four-digit year value." >&2; exit 1 #fi # Is the month input format a number? #if [ -z $(echo $1|sed 's/[[:digit:]]//g') ]; then # monthNumToName $1 #else # Normalize to first three letters, first upper-, rest lowercase. # month="$(echo $1|cut -c1|tr '[:lower:]' '[:upper:]')" # month="$month$(echo $1|cut -c2-3 | tr '[:upper:]' '[:lower:]')" #fi #echo $month $2 $3 #exit 0