On Tue, Dec 21, 2010 at 08:30:43PM +0200, Roland RoLaNd wrote: (chuckle) That's a bit more verbose than necessary. As a one-liner: awk -F, '($4>"09:00:00"){c[$2 "," $3]++};END{for (i in c){print i "," c[i]}}' $filename 01368,2010-12-02,4 01368,2010-12-03,3 (You might check if you want >="09:00:00", and include the edge case.) -F, # set separator to comma # (automatic loop over all data lines) ($4>"09:00:00"){ # do if fourth field greater than 09:... c[$2 "," $3]++ # increment hash element pointed to by # second and third fields separated by comma # (that is, hash on id,date) END{ # after finishing the data for (i in c){ # for each observed hash value in array c print i "," c[i] # print the hash value, comma, count -- lundin at fini.net