LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 07-30-2009, 08:07 AM   #1
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Rep: Reputation: 0
filter log file


Hi
I need to filter a log file.
I need to do something like: cat logfile | egrep '(X|Y)' but i need that X and Y will not be a part of word these the Complete word.
I know i need to use "awk".
is anyone can help me please.
 
Old 07-30-2009, 08:23 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Look at the grep manpage. GNU egrep has the -w option to match entire words.
 
Old 07-30-2009, 08:25 AM   #3
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 53
what about `cat logfile | egrep '( X | Y )'`
 
Old 07-30-2009, 08:39 AM   #4
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 57
How does 'egrep -w "(X|Y)" logfile | do_something_with_resulting_log_entries ' turn out for you?
 
Old 07-30-2009, 08:49 AM   #5
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
-w do the work.
10x

now i need to do the next step is to count how many time X and Y appear in the log but not the SUM of them like:
cat logfile | egrep -wc '(X|Y)'
i don't mind to use a bash script who do it.
 
Old 07-30-2009, 08:54 AM   #6
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 57
egrep -wc "X" logfile; egrep -wc "Y" logfile
 
  


Reply

Tags
awk, filter, grep


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
setting file permissions for file /var/log/Xorg.0.log mfb Linux - Security 1 07-07-2009 01:41 PM
Help with rsync filter file Meson Linux - General 1 09-29-2008 06:59 PM
Filter file sharing inaki General 3 01-12-2007 07:46 AM
any ideas to reduce log file size or make log file size managed? George2 Programming 2 08-13-2006 06:55 AM
Script filter a file onradius Programming 4 02-21-2006 07:38 PM


All times are GMT -5. The time now is 09:55 PM.

Main Menu
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