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
grep from file jaydeep_sadaria Shell Programming and Scripting 2 04-10-2008 01:03 PM
grep file ali560045 Shell Programming and Scripting 0 01-10-2008 07:51 AM
How to grep a number in a file to find them in another file ahjiefreak Shell Programming and Scripting 7 12-12-2007 06:01 AM
how to search -n in a file with grep lamilami Shell Programming and Scripting 2 11-28-2007 04:42 PM
grep for a tar File steiner UNIX for Advanced & Expert Users 1 07-19-2004 12:40 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 05-27-2008
cbo0485 cbo0485 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 87
Grep Log file

Okay, I got a log file, and I need to use a combo of the tail -f command and the grep command, but I don't want to see all the output, other than what I'm "grepping". As well I'd like it to stop tailing and searching and just return to the command line, once it finds 1 line with that string in it. Something like this:

./scriptThatGeneratesLogFile.sh; tail -f | grep RUN logfile.out

Edit:

It doesn't have to be the grep command, or even the tail command. Those are just the two I'm somewhat familiar with and use the most.
  #2 (permalink)  
Old 05-28-2008
Tornado's Avatar
Tornado Tornado is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Location: Melbourne
Posts: 249
You could use a combination of comm and grep.

The logic in your script would look something like this:
- save a copy of your log file to logfile1
- wait a few minutes and save a copy of your logfile to logfile2
- comm -13 logfile1 logfile2 | grep the line your looking for
- exit if grep returns something, if it doesn't wait a few minutes.
- copy logfile2 to logfile1 and copy the new updated logfile to logfile2
- run your comm , grep command again and repeat your checks
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 02:26 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