Saturday, August 3, 2019

UNIX Tips: Use 'less +F --follow-name' instead of 'tail'

OK, so you need to watch a log's output for errors. You use 'tail -100f catalina.out' but the log scrolls too fast for you to see errors properly.

So you have to use ctrl+c to stop the tail process and then the mouse wheel to scroll up to where your error appeared. There has to better way!

Well, there is- instead of tail use 'less +F --follow-name catalina.out'.

You will immediately find yourself seeing the end of the file and whenever you see your error show hit ctrl+c.. you will still be in less but have the ability to scroll up and down using the j and key keys or ctrl+u and ctrl+d. To jump back into 'tail' mode just hit shift+F.

What's great about the '--follow-name' parameter is that even if the log rolls over less will seamlessly continue to tail your file.

I personally add 'alias follow=less +F --follow-name' to my .bashrc as soon as I get an account on the machine.

UNIX Tips: Use 'less +F --follow-name' instead of 'tail'

OK, so you need to watch a log's output for errors. You use 'tail -100f catalina.out' but the log scrolls too fast for you to se...