Maybe this one is common knowledge, but it caught me off guard.  And it might 
save somebody some time.

Assume we have a logfile.  To watch it on your terminal, you 
could type 'tail -f logfile'.

To filter the output, you could use 'tail -f logfile | grep foo'.

All as expected.  But you want more filtering, so you type:
'tail -f logfile | grep foo | grep bar'

And get no output at all, even though there are log entries that contain both 
foo and bar!

It turns out that a pipe has a buffer of 4096 characters and is holding the
data.  To make it work, you need:
'tail -f logfile | grep --line-buffer foo | grep bar'
and now you get the filtered output as expected.

--Brian


-- 
I think my life is fuller because I realize
that I don't know what I'm doing.
I'm delighted with the width of the world!
                        ---Richard Feynman


Brian Daniels                  [EMAIL PROTECTED]
      http://www.eviloverlord.net

-- 
TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ  : http://trilug.org/faq/
TriLUG Member Services FAQ : http://members.trilug.org/services_faq/

Reply via email to