# gett21ovhpre.awk # create contiguous date ranges for extensions { f = 0 p_ggrid = $(++f) p_siteid = $(++f) p_egrid = $(++f) p_extn = $(++f) p_hdate = $(++f) lst_dd = 0 + substr(lst_hdate,1,2) p_dd = 0 + substr(p_hdate,1,2) # contiguous dates for extn if ( lst_hdate == "" || ((p_dd == (lst_dd + 1)) && p_ggrid == lst_ggrid && p_siteid == lst_siteid && p_egrid == lst_egrid && p_extn == lst_extn)) { if ( lst_hdate == "" ) { # first rec c_sdate = p_hdate } } else { c_edate = lst_hdate print lst_ggrid "|" lst_siteid "|" lst_egrid "|" lst_extn "|" c_sdate "|" c_edate # new extn c_sdate = p_hdate c_edate = "" } lst_hdate = p_hdate lst_ggrid = p_ggrid lst_siteid = p_siteid lst_egrid = p_egrid lst_extn = p_extn } END { if ( lst_hdate != "" ) { c_edate = lst_hdate print lst_ggrid "|" lst_siteid "|" lst_egrid "|" lst_extn "|" c_sdate "|" c_edate } }