I want to redirect the filtered output of a tail -f, as follows:

tail -f myfile | egrep '(searchterm_a)|(searchterm_b)' >> outputfile.txt

But for some reason the redirection is not working as I would have expected it to. Instead, an empty file is created.

Does anyone have an idea of where I have made an error?

link|improve this question
Are you sure that your 2 part egrep search target works as you expect? What happens if you leave out the >> outFile. It might help to make a test file that has the values you are searching for execute that as egrep 'pat1|pat2' testFile, to be sure your patterns are working. My apologies if this is obvious for you, no offence intended ;-)! – shellter Apr 8 '11 at 17:31
feedback

1 Answer

Probably it's a buffering issue (see e.g. a very similar problem). You could try for example:

tail -f myfile | egrep --line-buffered '(searchterm_a)|(searchterm_b)' >> outputfile.txt
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.