Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count sum of clients 1

Status
Not open for further replies.

AnotherAlan

Technical User
Feb 10, 2006
362
GB
Hi all,

I am using the below awk line to total the byte count per client, but would like to include another column that sums the number of incidences of each client in $3.

awk '{t[$3]+=$11}END{for(i in t)print i,t|"sort -n"}'

Expected output would be;

client1 <byte count> <number of times client1 present>
client2 <byte count> <number of times client2 present>
...

I can then use these figures to produce a rolling average.

I am way too inexperienced with awk to figure this out.
Any help would be much appreciated.

Thanks
Alan
 
include another column
Which ? Here an example for col14:
awk '{t[$3]+=$11;x[$3]+=$14}END{for(i in t)print i,t,x|"sort -n"}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the reply PHV,

I maybe didn't explain correctly.
At present my ouput is;

client1 <bytecount>
client2 <bytecount>

I would like to produce a further sum to be included in the output as another column / field showing the total incidences of each client.
i.e If there are three occurences of clientx in the file then;

clientx <byte count> 3 ...e.t.c

BTW, the awk line I am using is a previous one of yours, so thanks for that.

Cheers
 
Got it,

Thanks for putting me on the right track PHV.

awk '{t[$3]+=$11;x[$3]++}END{for(i in t)print i,t,x|"sort -n"}'

Just what I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top