8

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?

  • I know this is not what you're asking for but could less | grep whatyourlooking could e a solution ? – Kiwy Nov 29 '13 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 '13 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.) – ctrl-alt-delor Nov 29 '13 at 10:13
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).

  • Thanks, it is not ideal but an acceptable solution – apartridge Nov 29 '13 at 10:23
0
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.