如何在不取消正在運行的進程的情況下取消「less」中「ESC-F」的效果?

如何在不取消正在運行的進程的情況下取消「less」中「ESC-F」的效果?

當我使用 時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-KlessFEsc-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選項也能對其產生相同的效果。

相關內容