ccze with `tail -f` and `grep`
lvillanne-recia opened this issue · 1 comments
lvillanne-recia commented
When I use ccze
with tail -f
and grep
sometimes some lines at the end of the file that should be displayed are not.
For example, with this very simple :
echo "foo" > foo.txt
If I just do a tail -f
on it, it works:
$ tail -f foo.txt | ccze -A
foo
If I just do a tail
and a grep
on it, it works:
$ tail foo.txt | grep "foo" | ccze -A
foo
If I do a tail -f
and a grep
without ccze
it works:
$ tail -f foo.txt | grep "foo"
foo
But if I do a tail -f
and a grep
with ccze
it doesn't work, no line is displayed:
$ tail -f foo.txt | grep "foo" | ccze -A
I've also tested disabling grep colouring, which doesn't change anything:
$ tail -f foo.txt | grep "foo" --color=never | ccze -A
lvillanne-recia commented
I found out what the problem was. It's a buffer problem in grep, just add the --line-buffered
argument to grep and it will work :
$ tail -f foo.txt | grep "foo" --color=never --line-buffered | ccze -A
foo
So the problem had nothing to do with ccze
as the same behaviour is reproducible with cat
.