LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 01-27-2009, 10:27 AM   #1
mariogarcia
Member
 
Registered: Sep 2005
Distribution: debian, solaris 10
Posts: 192

Rep: Reputation: 31
help with regular expressions


hello
i am trying to write a regular expression that scan a log file using and returns all the lines that have the word "ERROR" in them...

i am using a program called logsurfer; but regexp are very difficult for me to understand

so i tried this,

i have lines in the log file that look like this :

12:47:36,487 ERROR [smb.protocol.auth] No valid CIFS authentication combination
available
12:47:36,487 ERROR [smb.protocol.auth] Either enable Kerberos support or use an
authentication component that supports MD4 hashed passwords
12:47:36,491 ERROR [alfresco.smb.protocol] CIFS server configuration error, Inva
lid CIFS authenticator configuration
org.alfresco.error.AlfrescoRuntimeException: Invalid CIFS authenticator configur
ation


I have to write a regex that scans the file finds the lines with ERROR and reports the whole line.

i tried doing this :
".*[ERROR].*"

is this regex correct; will it return all the lines that have the word error in the logfile. there are lines of the file that doesn't have this word and they can be ignored.

if you can provide me any help of hints i'll be greatly grateful.

thank you in advance;
 
Old 01-27-2009, 10:30 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Maybe I'm missing something, but does not a simple grep do what you're trying to do?
Code:
 grep ERROR logfile
Edit: oops... sorry, I just noticed you are using a program called logsurfer to do that. Well... usually a regular expression is embedded in slashes, not square brackets. Maybe you are simply looking for
Code:
/ERROR/
whereas square brackets in a pattern mean a character list, that is not the whole word "ERROR" but a list of single characters "E", "R", "O" with "R" repeated 3 times. Unless logsurfer has its own syntax, but sincerely I doubt it...

Last edited by colucix; 01-27-2009 at 10:34 AM.
 
Old 01-27-2009, 11:48 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
If that fails, try
Code:
.*ERROR.*
Dave
 
Old 01-28-2009, 04:23 AM   #4
mariogarcia
Member
 
Registered: Sep 2005
Distribution: debian, solaris 10
Posts: 192

Original Poster
Rep: Reputation: 31
thank you for your help
i tried "\<ERROR\>" it seems to work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expressions bhuwan Programming 5 02-26-2006 12:07 AM
regular expressions. stomach Linux - Software 1 02-10-2006 07:41 AM
Regular Expressions markjuggles Programming 2 05-05-2005 12:39 PM
Regular expressions aromes Linux - General 1 10-15-2003 01:29 PM
regular expressions? alaios Linux - General 2 06-11-2003 04:51 PM


All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration