[PLUG] Making instant tee
Martin A. Brown
martin at linux-ip.net
Mon Mar 19 02:43:14 UTC 2012
Hello,
: How can I change the "tee" command so that it stops buffering and
: displays the immediate results?
Is something upstream of your tee command buffering? Are you
feeding your tee with the output of a grep? Why do I ask?
Try this:
{ while : ; do date --rfc-822 && sleep 3 ; done ; } \
| tee outfile
I do not see tee buffering anything.
If I stick an fgrep in there, I get some buffering (by grep):
{ while : ; do date --rfc-822 && sleep 3 ; done ; } \
| fgrep 'Mar' \
| tee outfile
What is writing to the input pipe of tee? Is that program checking
to see if it is connected to a terminal and behaving differently
when not connected to a terminal? Is this grep? If it is grep, how
about throwing the --line-buffered option?
{ while : ; do date --rfc-822 && sleep 3 ; done ; } \
| fgrep --line-buffered 'Mar' \
| tee outfile
: Or is this better done by the "tail -f" command?
Depends on what you are trying to accomplish. You don't show the
command. You explain what you expect to see, but given what you
have said so far, we can only guess that you are calling the program
tee and not getting the results you want.
: I wish there was an option to tee so that the user could see
: things happening right away, rather than wait for a 4K or some
: size buffer to fill up, which might take hours, in some cases.
Ah, yes, precious old 4k PIPE_BUF.
getconf -a | fgrep PIPE_BUF
PIPE_BUF 4096
_POSIX_PIPE_BUF 4096
I'll ask again: are you certain that tee is buffering?
I will admit to always having some bufferin with tea, though.
Let's try T for a change of pace.
Have a good evening,
-Martin
--
Martin A. Brown
http://linux-ip.net/
More information about the PLUG
mailing list