Code Comments
Programming Forum and web based access to our favorite programming groups.This must be a simple one... I need to find the count of lines falling into specific dates in a .dat file dynamically. (ie) for each unique date (Y/M/D excluding time) it should give out totals. This is how the file will look: 0|3|2005/05/01 23:10:49||733422094 0|3|2005/05/01 23:47:23||733823935 0|3|2005/05/02 04:03:45||734677852 0|5|2005/05/02 00:01:27||715880879 0|3|2005/05/01 23:41:01||734394379 0|3|2005/05/01 23:46:27||733823935 0|2|2005/05/02 05:12:24||733091614 0|3|2005/05/01 23:47:56||733823935 In this case I need the output to display 2005/05/01 5 2005/05/02 3 | - is the field seperator. Let me know if anybody has any scripts handy. Thx Rex
Post Follow-up to this message
Benz wrote:
> This must be a simple one...
>
> I need to find the count of lines falling into specific dates in a .dat
> file dynamically. (ie) for each unique date (Y/M/D excluding time) it
> should give out totals.
>
> This is how the file will look:
>
> 0|3|2005/05/01 23:10:49||733422094
> 0|3|2005/05/01 23:47:23||733823935
> 0|3|2005/05/02 04:03:45||734677852
> 0|5|2005/05/02 00:01:27||715880879
> 0|3|2005/05/01 23:41:01||734394379
> 0|3|2005/05/01 23:46:27||733823935
> 0|2|2005/05/02 05:12:24||733091614
> 0|3|2005/05/01 23:47:56||733823935
>
> In this case I need the output to display
> 2005/05/01 5
> 2005/05/02 3
>
> | - is the field seperator.
>
> Let me know if anybody has any scripts handy.
>
> Thx Rex
>
gawk -F"[| ]" '{c[$3]++}END{for (d in c) print d, c[d]}'
Ed.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.