10

I use less follow mode (Shift-F) to follow a log as it is updated. Sometimes it would be useful to do some actions on my system, and then only see log output related to that action. Basically I would need some way to clear the buffer so I'm not distracted by old stuff.

I can't find anything about it on the man page, but maybe there is some trick?

3
  • I know this is not what you're asking for but could less | grep whatyourlooking could e a solution ?
    – Kiwy
    Nov 29, 2013 at 9:05
  • I don't think so. Not really looking for something, just want to see the log after that action and optionally filter by /& as usual with less. Marks can solve the problem, but I would prefer just removing old stuff - then I can properly search in the newest input as well.
    – apartridge
    Nov 29, 2013 at 9:09
  • I got as far as less -C -j-1^C+G1u ", but when I added the F making less -C -j-1^C+G1u F", it went wrong. The F repositions the page. (+1 as I want to know the answer.) Nov 29, 2013 at 10:13

3 Answers 3

5

I doubt less has such an option.

What you're doing is very similar to what tail -f achieves, only with convenient scrollback. What you can do is quit current less and re-launch it with

     tail -f logfile -n lines_back | less

that way your buffer will contain only lines_back lines of the log (and should grow just the same).

1
  • Thanks, it is not ideal but an acceptable solution
    – apartridge
    Nov 29, 2013 at 10:23
1
less +F somelogfile

Any option in the COMMANDS section of the less man page can be prepended with +. For instance, this command finds the appropriate section in the manual:

man less | less +/COMMANDS
0

Use Ctrl-L to clear the terminal (on Windows/SuperPuTTY, different on Linux).

Then:

tail -n0 -f x.log

This displays a blank screen, and any new log lines will get added to the screen.

This is not less, but one can always run it under a different tab to retain the full power of scrollback and searching.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .