Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Aug 2010 10:26:30 -0400
From:      jhell <jhell@dataix.net>
To:        Gabor Kovesdan <gabor@freebsd.org>
Cc:        poyopoyo@puripuri.plala.or.jp, current@freebsd.org
Subject:   Re: bsdgrep does not work with tail -f | grep combination
Message-ID:  <4C597896.70800@dataix.net>
In-Reply-To: <4C585E44.5030608@FreeBSD.org>
References:  <86eiefhalp.wl%poyopoyo@puripuri.plala.or.jp> <4C585E44.5030608@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 08/03/2010 14:21, Gabor Kovesdan wrote:
> Em 2010.08.03. 19:25, poyopoyo@puripuri.plala.or.jp escreveu:
>> Hi,
>>
>> It seems bsdgrep does not work when piped from tail -f.
>> I'm running r210728.
>>
>> term0$ jot 10> /tmp/1
>> term0$ tail -f /tmp/1 | grep 0
>> [no output]
>>
>> otherterm$ jot 10>> /tmp/1
>> [no output to term0]
>>
>> =====
>>
>> with GNU grep:
>>
>> term0$ tail -f /tmp/1 | gnugrep 0
>> 10
>> otherterm$ jot 10>> /tmp/1
>> [on term0]
>> 10
>> 10
> I've checked on 8.0 and GNU grep doesn't output anything either for me.
> If you use tail -f, you will enter more lines and end it with EOF, won't
> you? And then BSD grep will process the input and print out matches. I
> don't think it's bad behaviour in itself but if you can explain why you
> think it's bad I'm willing to change it.
>

This is a common functionality gnu-grep. tail -f never exits and grep 
keeps grepping until it gets a EOF which is never hit unless you ^C.

A good example for such a use is monitoring a all.log log while looking 
for non-exact situations. something like

% tail -f all.log |egrep -v "(sendmail|sm-mta|cron)"

which would remove all lines that contain sendmail sm-mta & cron from 
the output and continue to read output from tail -f until it is ^C.

You can turn on your all.log through /etc/syslog.conf after creating the 
mode 600 file under /var/log for toying with.

There is quite a few other cases but I don't think I need to mention 
them. I rely on this for continuous firewall log trolling.

No offense but If the functionality exists in gnu-grep then the same 
functionality needs to exist in bsd-grep, ``period''. At least for the 
mean-time.


Regards,

-- 

  jhell,v




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C597896.70800>