[Top][All Lists]

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

Re: possible bug in coreutils?

From: Scott Griffith
Subject: Re: possible bug in coreutils?
Date: Thu, 23 Mar 2006 03:26:32 -0800 (PST)


     Thank you very much for your response.  I was just looking at the
man page for grep, and wouldn't you know it..  --line-buffer is not
very well documented.  Infact, all it says about that is:

(excerpt from man page)
              Use line buffering, it can be a performance penality.

     Your solution seems to be the missing piece.  When I piped in 350
lines of tail, your's worked where as mine still seems to hang there. 
I even tried to send my output to a file, and still nothing.  Maybe the
man page could get an update describing what --line-buffer actually
does?  Just a thought.

     Once again, Thank you very much for your assistance.  My work
around did the job, but I would much rather have it done in real time.
(or as close as possible without actually writing a C/C++ program)


Scott Griffith

--- Bob Proulx <address@hidden> wrote:

> You sent your message to bug-textutils which may indicate that you
> have a very old version.  The current programs are in the coreutils
> package and would have directed you to the bug-coreutils mailing
> list.  The current stable version is 5.94.  But that won't change
> anything for the purposes of your problem.
>   ftp://ftp.gnu.org/gnu/coreutils/coreutils-5.94.tar.gz   (7.6MB)
>   ftp://ftp.gnu.org/gnu/coreutils/coreutils-5.94.tar.bz2   (4.9MB)
> Scott Griffith wrote:
> > I am not sure if this is as designed, but the following produce
> results
> > that you would not expect:
> I think standard I/O file buffering is the reason here.
> >      cat /var/log/messages | grep -i fail | cut -f 9- -d ' '
> The 'cat' exits and buffers are flushed, the grep exits and buffers
> are flushed.  The cut writes to a tty and so output is not buffered.
> > using the following produces nothing, yet it should continually
> yield
> > the above messages when watching the system log:
> > 
> >       tail -f /var/log/messages | grep -i fail | cut -f 9- -d ' '
> I think they would, if you waited long enough, generated enough input
> to fill a large I/O buffer and allow the data to be written out.  But
> until that happens the data is in a standard I/O buffer pending more
> input.
> > however, I am able to use the following command and get output:
> > 
> >       tail -f /var/log/messages | grep -i fail
> In this command 'grep' writes to a tty instead of a pipe.  The C
> stdio
> library does not buffer when writing to a tty because it assumes a
> user is there.  But when writing to anything else, file or pipe, it
> does buffer.
> Try this:
>   tail -f /var/log/messages | grep --line-buffer -i fail | cut -f 9-
> -d ' '
> >      cat /var/log/messages | grep -i fail | cut -f 9- -d ' '
> By the way...  You don't need 'cat' in your above example.  Just use
> grep, remove the extraneous process, and redirect the input from the
> file directly.
>   grep -i fail < /var/log/messages | cut -f 9- -d ' '
> Also, because logs tend to get rotated by the system, you might want
> to look at the tail follow options.  Try --follow=name so that it can
> follow the rotations of the log file.
>   tail --follow=name /var/log/messages | grep --line-buffer -i fail |
> cut -f 9- -d ' '
> Hope that helps,
> Bob

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]