kuba , (edited )
@kuba@toot.kuba-orlik.name avatar

Ok so here's a linux question that's been bugging me for years.

I sometimes less to display/paginate a streaming stdout from another program. When I press END key on the keyboard, it brings me to the bottom of the stream, the latest data it has.

Then it says "Waiting for data... (^X or interrupt to abort)"

I want it to stop waiting for data and let me scroll up as it usually does when it's not waiting for data.

EDIT: Solved in

https://mastodon.social/@gnomon/112565743587893108

and

https://social.tchncs.de/@thomasmey/112565649508431258 🙏

HaraldKi ,
@HaraldKi@nrw.social avatar

@kuba „END“ key? Sounds weird. Try F (uppercase) and it will keep following the output dumping it into your terminal. Type CTRL-c to stop it following, now you can page normally through what came in so far. At any time press F again to have it follow and display incoming data.

DarkMetatron ,
@DarkMetatron@rollenspiel.social avatar

@kuba
The manpage says:

"When the "Waiting for data" message is displayed, such as while in the F command, pressing ^X will stop less from waiting and return to a prompt. This may cause less to think that the file ends at the current position, so it may be necessary to use the R or F command to see more data."

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

@DarkMetatron Neither of these work :<

thomasmey ,
@thomasmey@social.tchncs.de avatar

@kuba @DarkMetatron what terminal software do you use?

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

@thomasmey @DarkMetatron

gnome-terminal. I'm observing the same behavior in Console and xfce-terminal

thomasmey ,
@thomasmey@social.tchncs.de avatar
kuba OP ,
@kuba@toot.kuba-orlik.name avatar

@thomasmey That in fact works, thanks!

It's weird that journalctl invokes less in such an unintuitive way

ryanjyoder ,
@ryanjyoder@techhub.social avatar

@kuba I also need to know the answer to this. Sometimes I will work around this by dumping the output to a file in the background. And then doing less on that file.

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

I've tried pressing Control+X and Control+C, but it just closes less immediately instead of just interrupting the wait for new data.

What do I press to make it stop waiting for data, not just close itself?

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

This would particularly useful for browsing journalctl output 🙏

gnomon ,
@gnomon@mastodon.social avatar

@kuba you're doing the right thing! Or at least you're doing what should produce the result you want according to the default configuration of less(1).

However you say you're invoking less "indirectly" with journalctl; do you mean you're running journalctl ... | less, or just running journalctl and letting it invoke less(1) itself as the default pager? If the latter, it's useful to know that systemd invokes less with some quite non-default options!

https://github.com/systemd/systemd/blob/main/src/shared/pager.c

1/2

gnomon ,
@gnomon@mastodon.social avatar

@kuba If you consult the systemd documentation and the entries for $SYSTEMD_PAGER and $SYSTEMD_LESS¹ you'll find mention of some mysterious less(1) options but not what they mean or why they matter; but if you peek at the doc source code² you'll find that the behaviour you're describing is controlled by the presence of "K" in the default $SYSTEMD_LESS var, and you can override that out with, e.g.:

SYSTEMD_LESS='FRXM' journalctl  

¹: https://www.freedesktop.org/software/systemd/man/latest/systemd.html#$SYSTEMD_PAGER

²: https://github.com/systemd/systemd/blob/60a20eff8007105c4a09ab34ebe318d5970e629a/man/common-variables.xml#L112-L155

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

@gnomon OMG it works! Thank you!

gnomon ,
@gnomon@mastodon.social avatar

@kuba fantastic!! You're welcome! Thanks for giving me an opportunity to learn about this particular little stumbling block. I'll remember it for next time!!

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

@gnomon ❤️❤️❤️

thomasmey ,
@thomasmey@social.tchncs.de avatar

@kuba ctrl+c should stop waiting but not exit less

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

@thomasmey In my case it just kills less. At least when using less indirectly with journalctl

delta_onenature ,
@delta_onenature@mastodon.xyz avatar

@kuba

I believe a simple 'q' for quit should do the trick

kuba OP ,
@kuba@toot.kuba-orlik.name avatar

@delta_onenature pressing q has no effect for me :<

delta_onenature ,
@delta_onenature@mastodon.xyz avatar

@kuba

Correct. Ehen you use less normaly Capital F start reading new content at the end. In a bash session i can you CTRL+C stop/interrupt the mode back to the previous mode - not Endung less...

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • test
  • worldmews
  • mews
  • All magazines