In article <[EMAIL PROTECTED]>,
Martin F Krafft <[EMAIL PROTECTED]> wrote:
>hi,
>why does the following not work:
>
> tail -f /var/log/syslog | grep something | while read i; do myprog $i; done
It's because grep uses stdio, and it buffers the output at some
blocksize (1K / 4K / 16K or something) before it outputs anything
if the output is not a terminal .. not much you can do about it.
A solution would be:
tail -f /var/log/syslog |
while read i; do grep -q something "$i" && myprog "$i"; done
Or, more efficiently,
tail -f /var/log/syslog |
while read i
do
case "$i" in
*something*)
myprog "$i"
;;
esac
done
Mike.
--
"Answering above the the original message is called top posting. Sometimes
also called the Jeopardy style. Usenet is Q & A not A & Q." -- Bob Gootee