Grep to find single instances of each ERROR type


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep to find single instances of each ERROR type
# 1  
Old 05-26-2009
Grep to find single instances of each ERROR type

i have a file that contents multiple instances of the same ERROR.Below the content of the file

ERROR_FILE.txt
Code:
Archiver6.log:2009-05-25 17:58:44,385 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 2
Archiver6.log:2009-05-25 18:27:36,056 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 5
Cleaner3.log:2009-05-25 22:15:23,878 [Thread-8] ERROR - Channel information is not found in Siebel.
Cleaner3.log:2009-05-25 22:47:22,080 [Thread-8] ERROR - Channel information is not found in Siebel.
EventsAdapter.log:2009-05-25 10:57:21,034 [Timer-1] ERROR - Error in record. No PIPe mapping found for trbbitdesc=DIAG IND for serialnumber=10804396
EventsAdapter.log:2009-05-25 10:57:21,035 [Timer-1] ERROR - Error in record. No PIPe mapping found for trbbitdesc=DIAG IND for serialnumber=10804322
WMSAdapter.log:2009-05-25 08:11:01,313 [Timer-80] ERROR - Upload Process: WMS Activity for SR 1-1E2BKB not found in DB
WMSAdapter.log:2009-05-25 08:11:04,374 [Timer-80] ERROR - Upload Process: WMS Activity for SR 1-1E19FZ not found in DB
WMSAdapter.log:2009-05-25 08:11:07,274 [Timer-80] ERROR - Upload Process: WMS Activity for SR 1-1E19CZ not found in DB
WMSAdapter.log:2009-05-25 08:11:10,427 [Timer-80] ERROR - Upload Process: WMS Activity for SR 1-1E1965 not found in DB
WMSAdapter.log:2009-05-25 08:11:13,385 [Timer-80] ERROR - Upload Process: WMS Activity for SR 1-1E18J0 not found in DB

How am i suppose to get the single instances of each ERROR type from the above file?

Desired output:
Code:
Archiver6.log:2009-05-25 17:58:44,385 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 2
Cleaner3.log:2009-05-25 22:15:23,878 [Thread-8] ERROR - Channel information is not found in Siebel.
EventsAdapter.log:2009-05-25 10:57:21,035 [Timer-1] ERROR - Error in record. No PIPe mapping found for trbbitdesc=DIAG IND for serialnumber=10804322
WMSAdapter.log:2009-05-25 08:11:01,313 [Timer-80] ERROR - Upload Process: WMS Activity for SR 1-1E2BKB not found in DB

# 2  
Old 05-26-2009
How the Error's are same ?...

because the SR or serial number or intervals are varying in each line.

Or do you need to display just the error message ???
# 3  
Old 05-26-2009
let it make this way the output should display only the 1st ERROR of each type irrespective of difference in serial number or intervals

Code:
Archiver6.log:2009-05-25 17:58:44,385 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 2
Archiver6.log:2009-05-25 18:27:36,056 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 5
EventsAdapter.log:2009-05-25 10:57:21,034 [Timer-1] ERROR - Error in record. No PIPe mapping found for trbbitdesc=DIAG IND for serialnumber=10804396
EventsAdapter.log:2009-05-25 10:57:21,035 [Timer-1] ERROR - Error in record. No PIPe mapping found for trbbitdesc=DIAG IND for serialnumber=10804322

Desired output
Code:
Archiver6.log:2009-05-25 17:58:44,385 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 2
EventsAdapter.log:2009-05-25 10:57:21,034 [Timer-1] ERROR - Error in record. No PIPe mapping found for trbbitdesc=DIAG IND for serialnumber=10804396

# 4  
Old 05-26-2009
i tried this :

Code:
sort -u -k6,7 error_text

and got the output
Code:
Cleaner3.log:2009-05-25 22:15:23,878 [Thread-8] ERROR - Channel information is not found in Siebel.
Archiver6.log:2009-05-25 17:58:44,385 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 2
EventsAdapter.log:2009-05-25 10:57:21,034 [Timer-1] ERROR - Error in record. No PIPe mapping found for trbbitdesc=DIAG IND for serialnumber=10804396
WMSAdapter.log:2009-05-25 08:11:01,313 [Timer-80] ERROR - Upload Process: WMS Activity for SR 1-1E2BKB not found in DB

i hope this is wat ur looking for.
# 5  
Old 05-26-2009
Quote:
Originally Posted by ali560045
How am i suppose to get the single instances of each ERROR type from the above file?
after 300+ posts, you are not a newbie in scripting anymore. show what you have done.
# 6  
Old 05-26-2009
Here is a sample code that will give u uniq errors in file

===========code============

cat file | cut -d ':' -f1 | sort -u >temp.txt
rm text
touch text


while read line
do
echo $line
grep -h "$line" ars.txt | head -1 >> text

done < amitt
=============================
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep multiple instances and send email.

Removed (15 Replies)
Discussion started by: saisneha
15 Replies

2. Solaris

Error: svcs: Pattern 'pooladm.conf' doesn't match any instances

Hi, I got the following errors during zfs resource pool configuration. Please help. Thanks. # svcs *pool* svcs: Pattern 'pooladm.conf' doesn't match any instances STATE STIME FMRI # svcadm enable system/pools:default # svcs *pool* svcs: Pattern 'pooladm.conf' doesn't match any... (4 Replies)
Discussion started by: aixlover
4 Replies

3. UNIX and Linux Applications

grep file to find unique instances of username

hello - A SystemOut.log file has recurring entries that follow this format: Principal: auth9.nick.al.gov:389/USERNAME Over the course of a day thousands of lines similar to this are produced, with each username represented hundreds of times. I need to create a new file that shows... (4 Replies)
Discussion started by: 1075FJ40
4 Replies

4. Shell Programming and Scripting

awk/grep type question

Hi there, I have a Solaris machine with an ifconfig output similar to below lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2 inet... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

5. Shell Programming and Scripting

Grep with multiple instances of same pattern

Hi, This is my text file I'm trying to Grep. Apple Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received End My Grep command: grep only--matching 'Location.*Received' Because the keyword Received appears twice, the Grep command will stop at the last... (3 Replies)
Discussion started by: spywarebox
3 Replies

6. Shell Programming and Scripting

Grep with multiple instances of same pattern

Hi, This is my text file I'm trying to Grep. Apple Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received End My Grep command: grep only--matching 'Location.*Received' e. Because the keyword Received appears twice, the Grep command will stop at the last... (0 Replies)
Discussion started by: spywarebox
0 Replies

7. Shell Programming and Scripting

ksh : find value type

Hi, Simple question : How to find the value type from a variable : Ex : var="1" => type is numeric var="a" => type is character Thx :D (3 Replies)
Discussion started by: madmat
3 Replies

8. UNIX for Dummies Questions & Answers

grep exclude/find single and double quotes

Hello, I'm trying to use grep or egrep to exclude a whole range of characters but how do I exclude both a single and a double quote. It might be easier to say how do I use grep to find both single and double quotes. grep ' ' " ' file grep detects the first single quote within my... (4 Replies)
Discussion started by: Lindy_so
4 Replies

9. Shell Programming and Scripting

How to replace all string instances found by find+grep

Hello all Im performing find + grep operation that looks like this : find . -name "*.dsp" | xargs grep -on Project.lib | grep -v ':0' and I like to add to this one liner the possibility to replace the string " Project.lib" that found ( more then once in file ) with "Example.lib" how can I do... (0 Replies)
Discussion started by: umen
0 Replies

10. UNIX for Dummies Questions & Answers

find . -type d -exec cd {} \;

Hi all Can anyone tell me why this is not working ? i saw somewhere that i must have serach (execute) permission which i have but it still wont work thx (2 Replies)
Discussion started by: shimont
2 Replies
Login or Register to Ask a Question