Re: Awk Array Question
- From: AyOut <morty3e@xxxxxxxxx>
- Date: Thu, 30 Aug 2007 20:51:38 -0000
On Aug 30, 2:10 pm, Hermann Peifer <pei...@xxxxxx> wrote:
AyOut wrote:
I have a shell script that invokes an awk command on a file of the
following format:
(Date, Time)
2007-01-01, 00:00:00,121
2007-01-01, 00:00:00,311
2007-01-01, 00:00:00,432
...
...
2007-01-01, 00:01:10,778
2007-01-01, 00:01:10,981
2007-01-01, 00:01:11,121
...
...
The script I have basically parses the file and generates a comma
separated output of
Date, Time, Count
2007-01-01, 00:00:00, 3
2007-01-01, 00:01:10, 2
2007-01-01, 00:01:11, 1
The command looks like this:
awk '{++hr[$1,substr($2,1,9)]}END{for(item in hr)printf("%s%s\n",item,
hr[item])}' ${logfile} > ${logfile}.csv
At the end of the process I have an output of 86400 lines, too big for
Excel. I want to truncate the output to only output the max value in
any given minute and thus reduce the output to 1440 lines.
Try with substr($2,1,5)] instead of substr($2,1,9)].
Hermann
I thought about doing this, but that's only going to give me TPS
granularity at a minute level. Doing $2,1,9 allows me to capture the
hits per second. I.e.:
(counts)
22
23
20
...
...
22
24
21
The max second value for the above given minute would be 24.
.
- Follow-Ups:
- Re: Awk Array Question
- From: Hermann Peifer
- Re: Awk Array Question
- References:
- Awk Array Question
- From: AyOut
- Re: Awk Array Question
- From: Hermann Peifer
- Awk Array Question
- Prev by Date: Re: command substitution with cat
- Next by Date: Re: -n option for bash script
- Previous by thread: Re: Awk Array Question
- Next by thread: Re: Awk Array Question
- Index(es):
Relevant Pages
|