awk switch

Updated: 19 March 2024

Convert month short name to number

switch(month_str){
    case "Jan":
        month_num="01"
        break
    case "Feb":
        month_num="02"
        break
    case "Mar":
        month_num="03"
        break
    case "Apr":
        month_num="04"
        break
    case "May":
        month_num="05"
        break
    case "Jun":
        month_num="06"
        break
    case "Jul":
        month_num="07"
        break
    case "Aug":
        month_num="08"
        break
    case "Sep":
        month_num="09"
        break
    case "Oct":
        month_num="10"
        break
    case "Nov":
        month_num="11"
        break
    case "Dec":
        month_num="12"
        break
    }

Leave a comment