Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .