Reputation: 1614
Suppose I have a file t.txt with many lines containing 'a'. I m puzzled why this doesn't work:
cat <(tail -f t.txt | grep a)
The above command just hangs without printing anything, even though every line has a match. Is this because cat is waiting for output of "tail" instead of "grep"? How can I fix this?
Btw, I tried another variant with double process substitution:
cat <(grep a <(tail -f t.txt))
This also hangs without printing anything.
Does anyone have a clue?
Upvotes: 1
Views: 356
Reputation: 16146
For programs that don't take a --line-buffered
argument, you can use stdbuf
:
cat <(tail -f t.txt | stdbuf -oL grep a)
How this works is sheer magic; it's best not to think about it.
Upvotes: 2