2

All I wanted is to grep for specific lines in an ongoing log and re-direct it to some file..

tailf log | grep "some words"

Now, I want the above command output to get re-directed to some file in on-going basis....

I tried,

tailf log | grep "some words" >> file

But that doesn't seem to work. What am I missing?

Zelda
  • 6,262
  • 1
  • 23
  • 28
Gokul
  • 1,071
  • what happen ? empty file ? file with jump line ? nothing ? tailf only access file when modify. are you sure your log is not empty ? – Kiwy Feb 13 '14 at 13:19

1 Answers1

12

The issue is buffering.

Use the --line-buffered option to force grep to flush the buffer after every line:

tailf log | grep --line-buffered "some words" >> file
devnull
  • 10,691
  • Worked like a charm.. I have a little further requirement.. I will try that myself and see how it goes.. Thank you so much.. – Gokul Feb 13 '14 at 14:22