[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible bug with grep/sed/tail?
From: |
David Corlette |
Subject: |
Possible bug with grep/sed/tail? |
Date: |
Thu, 20 Nov 2008 08:53:05 -0700 |
Hello there,
I am not sure this is actually a bug as there may be reasons why it has to be
this way, but certainly these tools work counter to my expectations.
I am trying to read lines from a log file and pass them through grep or sed,
and then on to another tool (netcat, for example). What I am seeing is that:
A) # tail trace.txt | grep "com"
- WORKS: produces output
B) # tail trace.txt | grep "com" | cat
- WORKS: produces output
C) # tail -f trace.txt | grep "com"
- WORKS: produces output, then waits and reports new lines
D) # tail -f trace.txt | grep "com" | cat
- FAILS: no output from existing lines, never gets new data
Similarly:
A) # tail trace.txt | sed s/com/newcom/
- WORKS: produces output
B) # tail trace.txt | sed s/com/newcom/ | cat
- WORKS: produces output
C) # tail -f trace.txt | sed s/com/newcom/
- WORKS: produces output, then waits and reports new lines
D) # tail -f trace.txt | sed s/com/newcom/ | cat
- FAILS: no output even from existing lines, no new data reported
To me, it seems completely counterintuitive that A, B, and C would work, but D
does not. Each line of input read by tail should be passed to STDOUT, which is
then read as STDIN by grep/sed, then passed to STDOUT and read by cat. It
should not matter if tail is "done" reading the output or not, as clearly that
works fine in case C.
Thoughts? Is there some limitation of which I am not aware that prevents this
from working? Where does the data go in case D?
Details:
Linux moolap 2.6.16.60-0.30-smp #1 SMP Thu Aug 28 09:26:55 UTC 2008 x86_64
x86_64 x86_64 GNU/Linux
tail (GNU coreutils) 5.93
GNU sed version 4.1.4
grep (GNU grep) 2.5.1
- Possible bug with grep/sed/tail?,
David Corlette <=
- Re: Possible bug with grep/sed/tail?, Paolo Bonzini, 2008/11/20
- Re: Possible bug with grep/sed/tail?, Pádraig Brady, 2008/11/20
- Re: Possible bug with grep/sed/tail?, Brian Dessent, 2008/11/20
- Re: Possible bug with grep/sed/tail?, Jim Meyering, 2008/11/21
- Re: Possible bug with grep/sed/tail?, Reuben Thomas, 2008/11/21
- Re: Possible bug with grep/sed/tail?, Paolo Bonzini, 2008/11/21
- Re: Possible bug with grep/sed/tail?, Andreas Schwab, 2008/11/21