Unix Programming - multiple pipes and tail -f

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > August 2007 > multiple pipes and tail -f





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author multiple pipes and tail -f
pvsnmp@yahoo.com

2007-08-22, 1:23 pm

Hi,
I have been trying to do the following but it doesn't seem to work.
tail -f <filename> | grep <some string> | grep <some other string>

where <filename> is the name of any file to which new lines are added,
something like a log file for example.
Is there some restriction on the number of pipes which could be used
while using tail -f ?
I would like use sed instead of the last grep in the example above,
but for simplicity I have used second grep.

Thanks and Regards,
Prashant

Ivan Gotovchits

2007-08-22, 1:23 pm

pvsnmp@yahoo.com wrote:

> Hi,
> I have been trying to do the following but it doesn't seem to work.
> tail -f <filename> | grep <some string> | grep <some other string>
>
> where <filename> is the name of any file to which new lines are added,
> something like a log file for example.
> Is there some restriction on the number of pipes which could be used
> while using tail -f ?
> I would like use sed instead of the last grep in the example above,
> but for simplicity I have used second grep.
>
> Thanks and Regards,
> Prashant

I think it is better to ask it in comp.unix.shell

P.S. As I know, there're no restrictions.
Pipe Dope

2007-08-22, 7:23 pm

pvsnmp@yahoo.com wrote:

>Hi,
>I have been trying to do the following but it doesn't seem to work.
>tail -f <filename> | grep <some string> | grep <some other string>
>
>where <filename> is the name of any file to which new lines are added,
>something like a log file for example.
>Is there some restriction on the number of pipes which could be used
>while using tail -f ?
>I would like use sed instead of the last grep in the example above,
>but for simplicity I have used second grep.


You might be running into buffering issues.

Try "grep --line-buffered"

More at: http://www.pixelbeat.org/programming/stdio_buffering/
pvsnmp@yahoo.com

2007-08-23, 1:21 am

On Aug 23, 2:51 am, hates...@hatespam.com (Pipe Dope) wrote:
> pvs...@yahoo.com wrote:
>
>
> You might be running into buffering issues.
>
> Try "grep --line-buffered"
>
> More at:http://www.pixelbeat.org/programming/stdio_buffering/



Hi,
Yes, --line-buffered seems to work.

Thanks,
Prashant

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com