It is currently Sat, 09 Dec 2023 05:50:20 GMT

Author Message
 tail | grep | grep | grep
HI all,

I know this is a silly question, but i don't know the answer and i
figure that people here will....

I can do:

tail -f messages | grep -v assist

But why doesn't this work:

tail -f messages | grep -v assist | grep -v cron

And so on with a few more greps as wanted?

I can't work it out, maybe my brain ain't working properly......


 Wed, 02 Aug 2006 22:41:21 GMT   
 tail | grep | grep | grep

when grep writes to a tty, it does line buffering.  when it writes to
a pipe, it does block buffering (4 KiB?).  if you install GNU grep,
you can override this behaviour with --line-buffered

Kjetil T.

 Wed, 02 Aug 2006 23:28:11 GMT   
 tail | grep | grep | grep
'grep -v cron' greps 'cron' from 'grep -v assist' output? Confusing enough?


 Wed, 02 Aug 2006 23:34:18 GMT   
 tail | grep | grep | grep
Hash: SHA1

In what way does that not work?

Since the output of the first grep is not to a terminal, it will be
buffered.  The second grep won't see anything until there is enough
in the buffer (maybe something like 1K or so of output).  The effect
is that there may be long periods with no output from the final
stage, followed by a whole bunch of lines.

That just increases the number of buffering layers.

It will be more responsive to use

        tail -f messages | egrep -v 'assist|cron'

Version: GnuPG v1.2.4 (SunOS)


 Wed, 02 Aug 2006 23:37:06 GMT   
 tail | grep | grep | grep

Thanks Neil et all, I hadn't put that together at all.


 Thu, 03 Aug 2006 00:03:37 GMT   
   [ 5 post ] 

Similar Threads

1. grep sTerm * | grep -v grep ???

2. Bug in grep or man grep

3. PLEASE HELP A NEWBIE: grep doesn't grep

4. grep question New to grep

5. grep attempts to grep in non-ascii files

6. /bin/grep vs /usr/ucb/grep

7. lscfg | grep en and then grep lo

8. grep and grep -o line count differ

9. Using grep -v and grep -C together

10. grep [f]oo and grep foo differences

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software