[NTLUG:Discuss] More from the Saturday topic of "Less is More..."
Steve Baker
sjbaker1 at airmail.net
Tue Apr 19 23:12:20 CDT 2005
>>> Actually "tail -f | grep something" works quite well. I guess I was
>>> trying to do it the other way round, "grep something | tail -f" which
>>> does not work.
Both ways 'work' - they just do different things.
If you grep first then the 'tail' will show the last screenful of output
from grep - but because the '|' pipe does buffering, it might take
a while for enough output to emerge from grep to trigger tail into
displaying it...which is probably why it didn't seem to work for you.
Doing the tail first changes that around - but now instead of seeing
the last screenful of grepped output, you are seeing the result of
running grep on the last screenful of input - which is a VERY different
thing.
Working with shell pipelines is an amazingly powerful thing - but
the results may be unexpected if you don't understand what's going on
under the hood and if you don't have a mental library of a few hundred
handy little command line widgets to do things with the stdin/stdout/stderr
streams.
---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1 at airmail.net> WorkEmail: <sjbaker at link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----
More information about the Discuss
mailing list