I have a log file A that is constantly updated (but it is rolled over) and I need to constantly filter it's content and write to a persistent file.
I need to:
tail -f A.log | grep "keyword" >> B.log
grep, without writing to the file, works, you encountered a buffering "problem". I/O buffering, unless manually implemented by the program will get handled by the libc. If the program's stdout is a termial, buffering will be line-based. If not, the libc buffers output until the buffer reached a size limit.
On Linux, meaning with
glibc you can use the
stdbuf command to configure that buffering:
tail -f A.log | stdbuf -oL grep "keyword" >> B.log
-oL specifies that the output stream should be line-buffered.