On Tue, Dec 21, 2010 at 02:35:13PM -0500, m.roth at 5-cent.us wrote: > John Lundin wrote: > > On Tue, Dec 21, 2010 at 08:30:43PM +0200, Roland RoLaNd wrote: [...] > Well, yes, but he also wanted a count.... Oh, lord, it's worse than that. I was solving the wrong problem. (And still am if he really wanted a count of after-nine entries.) Once again with awk one-liners: awk -F, '{k=$2 "," $3};(!e[k]||($4<e[k])){e[k]=$4}\ ;END{for (i in e){if (e[i]>"09:00:00"){print i "," e[i]}}}' infile \ |tee latedays\ |awk -F, '{c[$1]++};END{for (i in c){print i "," c[i]}}' >latecounts 01368,2010-12-02,09:07:00 01368,2010-12-03,09:02:00 01368,2 You may now wince. If earliest time seen for user and date is undefined or if this time is less, then set earliest time to this time. After all processed, print out the user, date and time if it's later than 09:00:00. Second awk script just counts lines reported above, by user. (I usually switch to perl or at least a bash script file before it gets this unreadable. And add some sanity testing.) -- lundin at fini.net "I have a photographic memory. If only I could remember where I left the film..."