The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Build Error: error: dereferencing pointer to incomplete type katwala UNIX for Dummies Questions & Answers 8 04-17-2009 09:16 AM
ksh : find value type madmat Shell Programming and Scripting 3 04-10-2009 02:35 PM
grep exclude/find single and double quotes Lindy_so UNIX for Dummies Questions & Answers 4 03-06-2008 09:01 AM
How to replace all string instances found by find+grep umen Shell Programming and Scripting 0 12-06-2007 03:52 AM
find . -type d -exec cd {} \; shimont UNIX for Dummies Questions & Answers 2 11-23-2005 11:42 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-26-2009
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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 (permalink)  
Old 05-26-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 457
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 (permalink)  
Old 05-26-2009
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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 (permalink)  
Old 05-26-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 457
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 (permalink)  
Old 05-26-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,422
Quote:
Originally Posted by ali560045 View Post
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 (permalink)  
Old 05-26-2009
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
  
 

Join Date: Jan 2009
Location: Gurgaon,INDIA
Posts: 239
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
=============================
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0