Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Grep command in a loop

UNIX for Beginners Questions & Answers


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 6 Days Ago   -   Original Discussion by MSpeare
MSpeare's Unix or Linux Image
MSpeare MSpeare is offline
Registered User
 
Join Date: May 2018
Last Activity: 20 May 2018, 3:24 PM EDT
Posts: 7
Thanks: 1
Thanked 1 Time in 1 Post
Grep command in a loop

Hello -

I am running a script that is outputting to a log. Let call it output.log
I would like to monitor that log until the line "Build Successful" is found.

I think I would need to use the grep command.
How would I do that in a loop?

Thanks
Marty
Sponsored Links
    #2  
Old Unix and Linux 6 Days Ago   -   Original Discussion by MSpeare
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 22 May 2018, 3:03 PM EDT
Location: Saskatchewan
Posts: 22,674
Thanks: 1,177
Thanked 4,321 Times in 3,984 Posts
It'd be much better to watch the return code of the script if you can. Usually it will return 0 for success, anything else for error.

You can do

Code:
tail -f build.log | grep -l -q "Build Successful"

but if "Build Successful" never appears, it will wait forever.

The same problem faces any approach really. Without some way to tell when it's failed, it has no termination condition.
The Following User Says Thank You to Corona688 For This Useful Post:
RavinderSingh13 (6 Days Ago)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
GREP loop jcllns1 Homework & Coursework Questions 7 02-20-2013 09:54 PM
using grep in a while loop guyiom Red Hat 5 02-02-2012 11:26 AM
Help on grep in a do while loop r4v3n Shell Programming and Scripting 3 06-24-2011 02:21 PM
grep -v while loop bobo UNIX for Dummies Questions & Answers 8 01-26-2007 09:53 PM
grep in a loop gundu Shell Programming and Scripting 7 03-28-2005 03:59 PM



All times are GMT -4. The time now is 12:39 PM.