当我使用 时less
,有时我喜欢让事情持续一段时间,所以我使用ESC-F序列键,到目前为止,它可以完成我想要的操作。
我发现返回正常less
命令的唯一方法是使用Ctrl-C.但是,当我这样做时,它会停止(取消)正在运行的进程。
我正在寻找一种在不停止正在运行的进程的情况下返回正常less
功能的方法,这样我就可以查看一些内容,然后看到以下输出,而无需重新启动我的进程。
有这样的能力吗?
答案1
正确答案是Ctrl+ X。
否则,在管道操作中,如find /var/log -name "*.log" | xargs less
, Ctrl+C将终止less
并退出以提示。
答案2
从手册页less
:
F Scroll forward, and keep trying to read when the end of file is
reached. Normally this command would be used when already at
the end of the file. It is a way to monitor the tail of a file
which is growing while it is being viewed. (The behavior is
similar to the "tail -f" command.)
ESC-F Like F, but as soon as a line is found which matches the last
search pattern, the terminal bell is rung and forward scrolling
stops.
如果您的标准选项列表(通常在环境变量或文件中less
指定,但也可能由 shell 别名或类似定义)包含,则在不退出的情况下不可能停止或函数:$LESS
~/.lesskey
-K
less
FEsc-Fless
-K or --quit-on-intr
Causes less to exit immediately (with status 2) when an inter‐
rupt character (usually ^C) is typed. Normally, an interrupt
character causes less to stop whatever it is doing and return to
its command prompt. Note that use of this option makes it im‐
possible to return to the command prompt from the "F" command.
因为Esc-F是该函数的一个变体F,所以我希望该-K
选项也能对其产生相同的效果。