6 ms·
I recommend using `less <FILE>` <shift-F> rather than plain `tail -f <FILE>` because you can ctrl-c to stop the tailing and then search the text using /. You ca
by dcsommer 5y ago
I recommend using `less <FILE>` <shift-F> rather than plain `tail -f <FILE>` because you can ctrl-c to stop the tailing and then search the text using /. You can then resume tailing again later with another <shift-F>.
- anyfoo 5y agoI love to press enter a few times to add a few empty lines to serve as a marker. Plus, I set my terminal scrollback buffer to 10000 lines (not a problem nowadays), so cmd-F in the terminal works pretty well. And I prefer the natural/kinetic scrolling of the terminal backlog to less as a fullscreen tty program. Finally, as the article alludes to, tail can monitor multiple files at once.
- pimlottc 5y ago> I love to press enter a few times to add a few empty lines to serve as a marker. Same! If it weren’t for this, I’d use less, as the searchability is often handy. But it’s funny how just one tiny (and possible unintended?) “feature” turns out to be so dang useful that I keep using tail.
- anyfoo 5y agoYeah, right? It's not even really a "feature" of anything, just an artifact of how teletype support was originally implemented in UNIX, and yet I've been hitting the enter key for my own "marks" for decades.
- a1369209993 5y ago> But it's funny how just one tiny (and possible unintended?) "feature" turns out to be so dang useful that I keep using tail. "Dangling by a trivial feature"[0] seems to be a pretty common issue when people recommend 'better' software. 0: http://prog21.dadgum.com/160.html http://prog21.dadgum.com/160.html
- ranko 5y agoless has its own system of bookmarks: use m followed by a lowercase letter to set a mark and single quote followed by a single letter to jump to that mark. I assume that this means we can have up to 26 bookmarks, though I normally don't go much beyond two.
- petepete 5y agoYou can use capital letters in less too, so at least 52.
- kevincox 5y agoI found myself doing this as well and decided to write a simple tool to do it "automatically" for me. You still can't use it with less, but at least it allows you to mark "segments" of the log without switching to that window and mashing enter. https://gitlab.com/kevincox/watchlog https://gitlab.com/kevincox/watchlog
- rzzzt 5y agotailf is also a good replacement for tail --follow=name, it uses inotify internally to only look at the file when there is a change.
- ithkuil 5y agoAnd you can also use the & command to filter (out) some patterns, while you're tailing.
- ryanmonroe 5y agoOr hit v after Ctrl-C to open it in a full editor (vi or whatever editor you have as $VISUAL). Quitting the editor resumes tailing.
- asdjlkadsjklads 5y agoOkay i wasn't interested in the `less` usage in the GP comment because i use tmux to stop and view logs as they're passing by. However automatically opening in my CLI editor? That sounds sexy as hell!
- iamthad 5y agoEquivalently, one can run `less +F <FILE>`
- ian-bateman 5y ago>couldn’t you pause/unpause the stdout with ctrl-s/ctrl-q instead? edit: child comment is a better solution.
- danielam 5y agoThis reads the entire file, so for large files you'll likely want something like `less -n +F` if you want to use `less`.
- emmelaich 5y agoAnother tip for `less`. bind next-file and prev-file to N and P instead of the default :n and :p. Makes it much more convenient to flip through files. [for some reason macos doesn't have the lesskey command even though it has the manual for it. shrug]
- rhizome 5y agoHow many times have you seen the last line of a file you're tailing be something like "00:00 Logfile turned over." Both less and tail stop doing their business when a log is rotated and the inode changes. Stop that by adding or extending an alias: alias less='less --follow-name' # still requires <shift>-f to follow alias tail='tail -F'
- c0l0 5y agoYou can stop output on a terminal (emulator) by exercising flow control. If you get overwhelmed by `tail` (or a similar tool's) output, hit ^S. If you are ready to resume, strike ^Q.
- bofh23 5y agoMy less(1) tips are: Use "-S" to toggle the "--chop-long-lines" option at invocation or in interactive mode. This mode shows only one line on the screen for each line in a file and is helpful when viewing a log with entries much longer than the screen width. When lines are chopped less(1) lets you scroll horizontally with <LEFTARROW>/<RIGHTARROW>. Chopped mode also works in tail mode ("F" command or "+F" option). As others have mentioned the search "/pattern" and filter "&pattern" commands are awesome and they also work in tail mode. The -J option toggles the status column which is helpful when using search patterns or paging around a file. Since less(1) has lots of features and navigation methods it’s good to remember the "h" command to show the help page.