Less is better, than tail

Jul 27 2009

I’ve been using tail to watch my log files for years:

tail -f log/production.log

It works great all the time, until you want to search for something, then you have to ctrl+c and open the file in less or vi.

Maybe there is a better way? After some googling, I found less is the answer:

less +F log/production.log

less +F works exactly like tail -f, with more:

  • Simply press ctrl+c to switch to editing model, so you can scroll backward and using any more/vi command, such as /pattern to search
  • Press shift+f again to switch back to tail model

Anyway, just run man less to find some more information.

Tags: , ,

8 responses so far

  1. [...] 声明,这是从人家的博客上读来的,地址在此。 Related Posts$c->detachchunzi@cpan.orgtaglist.vim on Mac [...]

  2. First result I found from google.

    Thanks for the tip, less works much better than tail for following fast moving/massive logs.

  3. Sure you can’t make an empty space beetween new entry and old, so something is difficult to understand new entries.

  4. great tip – thanks

  5. [...] Less is better, than tail (James) [...]

  6. Gordon DuQuesnay

    I usually tail -f from inside tmux. Tmux lets me scroll and search etc.

  7. Thank you for this useful tip.

  8. The “-R” option is handy to display the ANSI colour codes present in the log files.

    less +F -R log/production.log

Leave a Reply