Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

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

Your Answer

 
discard

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.