Live data from Hacker News

Stop using tail -f (mostly)

brianstorti.com

61–70 of 211 posts

Re: Stop using tail -f (mostly)

#61
post #54

If you're using a modern terminal with scrollback, you already have the ability to pause, and scroll back. # tail -f busy.log ctrl+s # Stops flow of output. pgup/pgdn for navigation # fn+up/dn for OS X users ctrl+q # Continues flow. No need to reinvent the wheel, the functionality you want is probably built into the tools you're already using.

This is not a replacement for searching for a specific string in `less` which highlights the matches, and eliminates the need for scanning the text manually which is harder and prone to missing information.

Most terminals also offer searching capability, which do not result in disk seeks on the remote host.

Re: Stop using tail -f (mostly)

#62
post #54

If you're using a modern terminal with scrollback, you already have the ability to pause, and scroll back. # tail -f busy.log ctrl+s # Stops flow of output. pgup/pgdn for navigation # fn+up/dn for OS X users ctrl+q # Continues flow. No need to reinvent the wheel, the functionality you want is probably built into the tools you're already using.

This is not a replacement for searching for a specific string in `less` which highlights the matches, and eliminates the need for scanning the text manually which is harder and prone to missing information.

Correct, however the author is saying that there's no reason to ever use tail unless you're tailing multiple files, which is false. Most of the functionality you want is already built into your terminal emulator. If you want slower updates (`less` uses 1 second polling, vs `tail` [inotify]), and the ability to search, by all means, use `less`.

Re: Stop using tail -f (mostly)

#65
post #30

Earlier quoted context omitted.

multitail is great. I really cannot use command line utils that don't support colors/highlighting anymore. htop instead of top, etc. It just gives me much better visibility and readability. I'm surprised that so many non-color utils are still being used. It just feels so 1994 to me to stare at a white on black display. I guess there's nothing more slow moving and conservative than shell interfaces, thus articles like…

Also take a look at ccze which is great for syntax-coloring all kinds of log files heuristically. For example: tail -F somefile.log|ccze -A For your shell, there's a lot of funky colorful interactive customizations you can get on zsh and fishfish.

That's really nice – thanks for the pointer. "ssh … varnishncsa | ccze" worked first time without any config, exactly as you'd want.

Re: Stop using tail -f (mostly)

#66

Earlier quoted context omitted.

Yeah, tail -F is the way to go imo. Also, if you are using a proper ssh client, opening a second ssh connection to manage the reacting to the log files is habit for me at this point. The only time I'm using tail -F is after a new configuration deployment. Otherwise, I'm looking at archival data in ELK.

Have you tried using screen[1]? Might make things a little easier than have two separate SSH connections. [1] https://www.gnu.org/software/screen/

c.f. tmux

Re: Stop using tail -f (mostly)

#67

Earlier quoted context omitted.

With less, you can use m to mark the current position and ' to go to a marked position. h will show you lots of useful help.

GP isn't meaning it like that, they mean being able to add some spaces so that the next log entries stand out for quick visual identification as you're making changes and reloading the application.

Use '/' (search) to enter a regexp to match a pattern on that line, and it will be highlighted.

Re: Stop using tail -f (mostly)

#68
I use tail -f mainly for tracking something end-to-end through multiple log files because it's pipeable to grep or awk, where less is not. less +F is cool too, but tail -f is more useful when doing complex log analysis on the fly because it follows standard UNIX I/O behavior.

Re: Stop using tail -f (mostly)

#69

For lazy people out there: There is also the command `tailf` which is quite similar to 'tail -f'. 2 characters make so much difference :)

alias tf='tail -f' I saved you three more!

GRUB_CMDLINE_LINUX_DEFAULT="init=/usr/bin/tail"

Maximum savings!

Re: Stop using tail -f (mostly)

#70
post #31

Earlier quoted context omitted.

With less, you can use m to mark the current position and ' to go to a marked position. h will show you lots of useful help.

An example of some of the vi commands that less(1) has adopted. You can also: * page forward and backward, including using numeric prefixes to indicate a lineno or indicate "repeat 'n' times". * launch vi if less(1) is working on a file (versus (eg) stdout of some process) * search fwd/backward * start examining a new file w/o leaving less(1) * ...

Just the other day I was looking for a way to do this in less:

yank 10 lines, open a new file, paste the 10 lines, save the file.

Is that possible? My Googling last week didn't find a good solution.

Post reply on HN