[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: grep | sed do not function inline?



On Mon, 2007-04-23 at 00:06 +0000, Tyler Smith wrote:
> On 2007-04-22, bilbo <bilbo@l-arrache.com> wrote:
> > log file which contains a lot of information. I wanted to extract some
> > informations out of it. But when I tried to
> >
> > tail -f mylog | grep 'smtg' | sed -n 's/end/notend/p'
> >
> > no output could be found. Which was quite surprising since the
> > following tests did their job without any problem:
> >
> > tail -200 mylog | grep 'smtg' | sed -n 's/end/notend/p'
> >
> 
> There is only one difference between these two lines - the first
> extracts the last 10 lines of mylog, the second extracts the last
> 200. The data you want is apparently not in the last 10 lines of
> mylog. 

Tyler, look at what "tail -f" it means (basically):

        -f, --follow[={name|descriptor}]
            output appended data as the file grows; -f, --follow, and
            --follow=descriptor are equivalent

Which mean it will sit watching the file/file-descriptor for appended
output and stay attached "forever" until broken out of.

I've used it for years as part of my "watch for certain things in the
logs" scripts.
-- 
greg, greg@gregfolkert.net

Novell's Directory Services is a competitive product to Microsoft's
Active Directory in much the same way that the Saturn V is a competitive
product to those dinky little model rockets that kids light off down at
the playfield. -- Thane Walkup

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: