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
Help me with parsing this file eamani_sun Shell Programming and Scripting 2 05-16-2008 03:39 PM
awk and file parsing devtakh Shell Programming and Scripting 4 05-06-2008 11:13 AM
Parsing a csv file chiru_h Shell Programming and Scripting 6 02-12-2008 09:33 AM
File Parsing jsusheel Shell Programming and Scripting 5 09-25-2007 10:25 AM
parsing file through awk bbeugie Shell Programming and Scripting 13 08-22-2006 01:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-19-2006
tbirenzweig tbirenzweig is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
Question Parsing a Log file

Hi All,

I'm deffently not a Unix specialist so be Gentel.
I need to parse a Log file that looks like that:

2006-06-12 01:00:00,463 ERROR [shared.logger.LoggerCleaner] {cleanLoggersFiles} General Error
comverse.compas.shared.exceptions.SystemParametersException: Error in reading parameter FileLocation
at comverse.compas.shared.paramhandler.SystemParametersDelegate.getStringValue(SystemParametersDelegate .java:186)
at comverse.compas.shared.logger.LoggerCleaner.cleanLoggersFiles(LoggerCleaner.java:110)
at comverse.compas.shared.logger.LoggerCleaner.run(LoggerCleaner.java:66)

My request is to Count the number of 'Error' occurences in the file in the current day, starting 00:00 till 00:00

Whats the best way to do that?

Thanks
Tal
  #2 (permalink)  
Old 06-19-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,418
Try this command :
Code:
grep -c "`date +'%Y-%m-%d'`[ 0-9:,]*ERROR" /path/to/log_file
Jean-Pierre.
  #3 (permalink)  
Old 06-19-2006
tbirenzweig tbirenzweig is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 2
Still doent work

Thanks Jean-Pierre,
I have tried the command but havent received the expected result. I have also tried your command by giving a specific date and it still doent work:

grep -c "2006-06-18 [0-9:,] *ERROR" SPMAgent_Debug.log
0
dsu001-sys01a:/var/cti/logs/spmagent ROOT > grep "2006-06-18" SPMAgent_Debug.log
2006-06-18 01:00:00,528 ERROR [shared.logger.LoggerCleaner] {cleanLoggersFiles} General Error

As U can see I hace the sring ERROR on the 18th but using the command I get the counter 0

any thoughts
Tal
  #4 (permalink)  
Old 06-19-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,719
I'm not sure what's going on - Jean-Pierre seems to have a good regex.
start with this:
Code:
grep '^2006-06-18 ' SPMAgent_Debug.log | grep -c ' ERROR '
  #5 (permalink)  
Old 06-20-2006
thestevew thestevew is offline
Registered User
  
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
Looks like a trypo?
You have:
Code:
grep -c "2006-06-18 [0-9:,] *ERROR" SPMAgent_Debug.log
instead of (the space is after the [, not before it)
Code:
grep -c "2006-06-18[ 0-9:,] *ERROR" SPMAgent_Debug.log
Closed Thread

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 04:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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