I am using ubuntu bash. I am trying to combine tail -f and less +F like below and nothing is coming out.

tail -f long_running_log | less +F

long_running_log is a log file constantly being written by another process. The following line will show a ton of stuff on the console: tail -f long_running_log But once I combine it with less +F with a pipe, nothing comes out.

In case you wonder why I am doing this, it is because I want to filter out the results of tail along the way. The real command looks like this: tail -f long_running_log | filter1 | filter2 | less +F

For debugging purposes, I removed filter1 and filter2 in the middle and still have problems.


From less man page:

   F      Scroll forward, and keep trying to read when the end of file is reached.  Normally  this  com-
          mand  would be used when already at the end of the file.  It is a way to monitor the tail of a
          file which is growing while it is being viewed.  (The behavior is similar  to  the  "tail  -f"

The problem is that as long as the pipeline is still running (i.e. tail is still running) you won't get EOF. You can check that with a Ctrl-C which kills the pipeline - the filtered output is then displayed.

You can either completely drop piping to 'less +F' (you'll get the filtered output progressively displayed in the terminal) or redirect the filtered output to another file which you can then monitor using 'less +F that_log_file'.

  • Then why is it possible to do less +F long_running_log_file and show the last parts of the log file just like tail -f but with more functionalities? – Tom Bennett Jun 4 '15 at 18:02
  • Because long_running_log_file is a "real" file and thus EOF is available at any moment for the 'less +F' functionality. – Dan Cornilescu Jun 4 '15 at 18:06
  • You will see the same effect if you pipe to less (without the +F) and press the End key. Both commands suspend while seeking end of file, which isn't reached until the pipe is closed. The p command behaves similarly, but it does tell you what it's doing, and prompts you to interrupt. – AFH Jun 4 '15 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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