Calculate date difference between $2,$3 from file in awk
问题 I would need your help. File with only date, file.txt P1,2013/jul/9,2013/jul/14 P2,2013/jul/14,2013/jul/6 P3,2013/jul/7,2013/jul/5 display output like this P1,2013/jul/9,2013/jul/14,5days P2,2013/jul/14,2013/jul/6,8days P3,2013/jul/7,2013/jul/5,2days 回答1: awk ' BEGIN { months = "jan feb mar apr may jun jul aug sep oct nov dec" OFS = FS = "," } function date2time(date, a,mon) { split(date, a, "/") mon = 1 + (index(months, a[2])-1)/4 return mktime(a[1] " " mon " " a[3] " 0 0 0") } function abs