: !/bin/sh # convert MMYYYY ($1) to MMM$2YYYY (stdout) # if no $2 defaults to " " awk -v "MMYYYY=$1" -v "sep=$2" ' BEGIN { monthstr[1] = "Jan"; monthstr[2] = "Feb"; monthstr[3] = "Mar"; monthstr[4] = "Apr"; monthstr[5] = "May"; monthstr[6] = "Jun"; monthstr[7] = "Jul"; monthstr[8] = "Aug"; monthstr[9] = "Sep"; monthstr[10] = "Oct"; monthstr[11] = "Nov"; monthstr[12] = "Dec"; billmm = 0 + substr(MMYYYY,1,2) billyyyy = 0 + substr(MMYYYY,3,4) if ( sep != "" ) sepchar = substr(sep,1,1) else sepchar = " " billperiod = monthstr[billmm] sepchar billyyyy print billperiod exit }' exit 0