Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|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

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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