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 4,229 other subscribers

Archive for November 7th, 2022

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

Posted in *nix, *nix-tools, less, Power User | Leave a Comment »

 
%d bloggers like this: