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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Ignore some lines with specific words from file comparison jakSun8 Shell Programming and Scripting 2 03-13-2008 12:11 AM
Tar Exclude Dir with a Specific Words rhartleyoh UNIX for Dummies Questions & Answers 1 07-26-2007 11:53 AM
Search files that all contain 4 specific words WoodenSword Shell Programming and Scripting 13 01-22-2007 06:57 AM
Search and replace words between two keywords vrrajeeb Shell Programming and Scripting 6 05-11-2005 01:15 PM
search for words in file Agent_Orange Shell Programming and Scripting 4 10-25-2002 06:29 AM

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 12-04-2007
mevasquez mevasquez is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 4
Search File for Specific Words

I have a file that contains the following:
Mon Dec 3 15:52:57 PST 2o007: FAILED TO PROCESSED FILE 200712030790881200.TXT - exit code=107
Tue Dec 4 09:08:57 PST 2007: FAILED TO PROCESSED FILE 200712030790879200a.TXT - exit code=107

This file also has a lot more stuff since it is a log file.
I am currently using the following but there must be a shorter way of doing it.
Code:
LOGDIR=/path/to/log/directory

grep FAILED $LOGDIR/processor.log | grep `date +20%y%m%d%y` | grep 107 > tempfile
I am trying the following but it does not work.

Code:
grep -E "FAILED[\w]*`date +20%y%m%d%y`[\w]*107
Also, how can I just grep this log file and get just the ones that have today's date and a.TXT on the line.

TIA
Mike
  #2 (permalink)  
Old 12-04-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Use %Y instead of 20%y for safety.
Code:
egrep "FAILED.*`date +%Y%m%d%y`.*107$" $LOGDIR/processor.log > tempfile
Quote:
Also, how can I just grep this log file and get just the ones that have today's date and a.TXT on the line.
Code:
egrep "^`date`.*\.TXT"
  #3 (permalink)  
Old 12-04-2007
mevasquez mevasquez is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 4
Thanks that worked great. I am pretty new to reg expressions. I do understand how you did it.

Mike
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 03:13 AM.


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