awk count how many unique IPs have received that error

Hi all,

I want to write a awk script that counts unique IPs that have received one special error.
For example

25-04-2012;192.168.70.31;1254545454545417;500.0;SUCCESS
25-04-2012;192.168.70.32;355666650914;315126423993;;General_ERROR_23
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-2012;192.168.70.33;e;null;null;Failure
30-04-201;192.168.70.34;e;null;null;ERROR_22
30-04-2012;192.168.70.37;e;null;null;Failure.
30-04-2012;192.168.70.10;e;null;null;Failure

The result should be:

Error name              Number of unique IPs

General_ERROR_23 =     1
Failure  = 3
ERROR_22  =  1  

etc...

Thank you very much!

Ervin

awk -F";" '! E[$2,$NF]++ { U[$NF]++ } END { for(ERR in U) printf("%s\t%s\n", ERR, U[ERR]); }' filename

One of your "Failure"'s is actually a "Failure." though. Is that intentional?

1 Like

Your double-posting wasted a lot of my time answering a question that was already answered.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.