Why does tail -f logfile | grep keyword | grep -v exclude-keyword react slow?
In other words, if I do a "tail -f logfile | grep keyword" I immediately see results. But if I pipe the output into another grep, then the results are delayed until some buffer is filled up or a certain amount of lines is sent. For Example: $ tail -f ~/logs/access.log | grep postfix 10.1.175.3 - - [01/May/2001:12:04:40 -0700] "GET /software/virtualmail-pop3d/postfix.html HTTP/1.0" 304 - "-" "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)" 10.160.213.200 - - [01/May/2001:12:05:02 -0700] "GET /software/virtualmail-pop3d/postfix.html HTTP/1.0" 200 7146 "-" "Lynx/2.8.2rel.1 libwww-FM/2.14" 10.160.213.200 - - [01/May/2001:12:07:53 -0700] "GET /software/virtualmail-pop3d/postfix.html HTTP/1.0" 200 7146 "-" "Lynx/2.8.2rel.1 libwww-FM/2.14" 10.160.213.200 - - [01/May/2001:12:07:55 -0700] "GET /software/virtualmail-pop3d/postfix.html HTTP/1.0" 200 7146 "-" "Lynx/2.8.2rel.1 libwww-FM/2.14" But when I do the following test: $ tail -f ~/logs/access.log | grep postfix | grep postfix Or: $ tail -f ~/logs/access.log | grep GET | grep -v BOGUS $ tail -f ~/logs/access.log | grep GET | grep G I get no results. I am watching the logs on another console and I know they are coming in. It does work if I use "cat" instead of "tail -f" So then I wait a while (maybe ten matches sent through) and it finally works. What causes this behaviour? What do I need to do to see the matches at once? For example, tail -f access.log | grep GET instantly shows many matches But tail -f access.log | grep GET doesn't display anything (unless I wait awhile for several future entries). By the way, I am using: grep (GNU grep) 2.4.2 tail (GNU textutils) 2. GNU bash, version 2.03.0(1)-release (i386-pc-linux-gnu) But I have now also seen this issue with different OSs and greps and tails. Jeremy C. Reed http://www.reedmedia.net/ http://bsd.reedmedia.net/ -- BSD news and resources http://www.isp-faq.com/ -- find answers to your questions