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.

Is it possible to execute cat logfile | tail -f? For some reason it just reads the initial log, but then it doesn't update incoming entries. I know I can directly do tail -f logfile.

I just wanted to know why this doesn't work, and if tail -f has to be always first and then another pipe?

share|improve this question
    
It's a good idea to get out of the habit of using cat uselessly. –  Dennis Williamson Dec 10 '10 at 16:57

1 Answer 1

up vote 4 down vote accepted

Just do tail -f logfile. When you do the cat first, you are cating the file as it is right now, and if you want to get new entries, you'll need to cat it again. If you just do tail -f logfile, then it will continually update the screen as the file updates (although you may wish to do tail -F logfile, so it will continue to work if the logfile is rolled over and a new one is created).

In other words, cat executes once and the output goes to tail. Running tail directly on the file causes tail to execute and stay running, so you continually get updates (with -f, that is).

share|improve this answer

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.