Less is better, than tail
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.
[...] 声明,这是从人家的博客上读来的,地址在此。 Related Posts$c->detachchunzi@cpan.orgtaglist.vim on Mac [...]
First result I found from google.
Thanks for the tip, less works much better than tail for following fast moving/massive logs.
Sure you can’t make an empty space beetween new entry and old, so something is difficult to understand new entries.
great tip – thanks
[...] Less is better, than tail (James) [...]
I usually tail -f from inside tmux. Tmux lets me scroll and search etc.
Thank you for this useful tip.
The “-R” option is handy to display the ANSI colour codes present in the log files.
less +F -R log/production.log