The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,949 other followers

Stop using tail -f (mostly)

Posted by jpluimers on 2022/11/07

Some interesting bits from [WayBack] Stop using tail -f (mostly):

  • say you want to watch the file production.log:
    $ less +F production.log
    
    Important
    log
    information
    here
    
    Waiting for data... (interrupt to abort)

    Here you have pretty much the same behaviour you’d get with tail.

    Now let’s say something interesting appears, and you want to search all the occurrences of “foo”. You can just hit Ctrl-c to go to “normal” less mode (as if you had opened the file without the +F flag), and then you have all the normal less features you’d expect, including the search with /foo. You can go to the next or previous occurrence with n or N, up and down with j and k, create marks with m and do all sort of things that less(1) says you can do.

    Once you are done, just hit F to go back to watching mode again. It’s that easy.

  • When you need to watch multiple files at the same time, tail -f can actually give you a better output.

Related: [WayBack] shell – The ‘less’ command-line equivalent of ‘tail -f’ – Unix & Linux Stack Exchange

I prefer tail -F

-F – The -F option implies the -f option, but tail will also check to see if the file being followed has been renamed or rotated.

The less equivalent: less +F --follow-name

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: