LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 09:27 AM   #1
mariogarcia
Member
 
Registered: Sep 2005
Distribution: debian, solaris 10
Posts: 202

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, 09:30 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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 09:34 AM.
 
Old 01-27-2009, 10:48 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

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

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


Reply



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-25-2006 11:07 PM
regular expressions. stomach Linux - Software 1 02-10-2006 06:41 AM
Regular Expressions markjuggles Programming 2 05-05-2005 11:39 AM
Regular expressions aromes Linux - General 1 10-15-2003 12:29 PM
regular expressions? alaios Linux - General 2 06-11-2003 03:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:31 PM.

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
Open Source Consulting | Domain Registration