awk count how many IP have received that error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk count how many IP have received that error
# 1  
Old 05-02-2012
awk count how many IP 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

Code:
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:

Code:
Error name              Number of unique IPs

General_ERROR_23 =     1
Failure  = 3
ERROR_22  =  1

etc...

Thank you very much!

Ervin

Last edited by joeyg; 05-02-2012 at 11:29 AM.. Reason: Wrap data, examples, and scripts inside of CodeTags.
# 2  
Old 05-02-2012
will the input actually have "Failure" and "Failure." and you need that folded together in the script, or was a typo in example?

Code:
[mute@geek ~]$ ./script input
Failure = 3
General_ERROR_23 = 1
ERROR_22 = 1
[mute@geek ~]$ cat script
#!/usr/bin/awk -f
BEGIN { FS=";" }
NF>5&&!a[$6,$2]++{e[$6]++}
END{for (i in e) print i " = " e[i]}

# 3  
Old 05-02-2012
Bug Thank you neutronscott!!

That was exactly what i needed!!!

THANK YOU SO MUCH!!
# 4  
Old 05-02-2012
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.
# 5  
Old 05-02-2012
Will keep this thread open. (Another Moderator was closing the other thread simultaneously).

Link to other thread, since some interesting ideas -->
https://www.unix.com/shell-programmin...#post302633733
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Error received

I have a program that i need to get done that gets the person's name and his grade then prints it in this order "name-grade-gradeletter" so i wrote this code: #!/bin/bash while :; do read -p "Enter the person's name: " name read -p "Enter the grade of the person: " grade case $grade in )... (3 Replies)
Discussion started by: UniverseCloud
3 Replies

2. AIX

Error received when I was trying to check state of boot record

Hello, This is a test/lab LPAR. Recently installed and updated the SP/TL. everything seems to be working fine. (ran all post install checks) I checked the state of boot record, received the following error/failed message. Can you please explain what does this mean ? />ipl_varyon -i ... (1 Reply)
Discussion started by: dio34
1 Replies

3. Shell Programming and Scripting

Error files count while coping files from source to destination locaton as well count success full

hi All, Any one answer my requirement. I have source location src_dir="/home/oracle/arun/IRMS-CM" My Target location dest_dir="/home/oracle/arun/LiveLink/IRMS-CM/$dc/$pc/$ct" my source text files check with below example.text file content $fn "\t" $dc "\t" $pc "\t" ... (3 Replies)
Discussion started by: sravanreddy
3 Replies

4. UNIX for Dummies Questions & Answers

How to count no. of received data of any one files?

Hi Guys, I have a file where is different task_id and every task id has many received data, now we have to count no. of received data for any task_id. (received means received words, i.e. count no. of received word of any task_id) Please help us Guys. (5 Replies)
Discussion started by: aaditya321
5 Replies

5. HP-UX

Received error as Not enough space left on device

Hi Forum, We have observed one problem in one of our HP-UX machines which runs a software which connects the radio frequency scan devices and the scanned information is stored in the database through the same software. This software has thrown an error like "Not enough space left on the... (4 Replies)
Discussion started by: Nishant.Jvk
4 Replies

6. Shell Programming and Scripting

awk - count character count of fields

Hello All, I got a requirement when I was working with a file. Say the file has unloads of data from a table in the form 1|121|asda|434|thesi|2012|05|24| 1|343|unit|09|best|2012|11|5| I was put into a scenario where I need the field count in all the lines in that file. It was simply... (6 Replies)
Discussion started by: PikK45
6 Replies

7. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: arrals_vl
2 Replies

8. AIX

nim: error signal number 2 received

Hi to all, i am trying to make mksysb backup of a NIM client machine from NIM master and while i am reading that the backup is done successfully i get an error message below and it doesnt exit the smit screen. also the status of the command appears to be running. is there anybody who knows why... (3 Replies)
Discussion started by: omonoiatis9
3 Replies

9. Solaris

"lpr.error] Warning: Received SIGPIPE" continuously appearing in logs

On a Solaris 8 print server we're continuously (every 2 minutes or so) getting these messages in the logs: printd: Warning: Received SIGPIPE; continuing I've applied this patch and restarted the printd daemon, but it doesn't help: #109320-22: SunOS 5.8: lp patch Does anyone have any idea what... (4 Replies)
Discussion started by: aussieos
4 Replies

10. UNIX for Dummies Questions & Answers

sorting received mail in unix and another error

hello! when issuing the mail command to see my received mail, i get this error: (server)starla:/home/starla>mail Warning: Too many letters, overflowing letters concatenated msgcnt 27378 vxfs: mesg 001: vx_nospace - /dev/vg00/lvol4 file system full (1 block extent) mail: no space for temp file... (0 Replies)
Discussion started by: starla0316
0 Replies
Login or Register to Ask a Question