更多/更少的分页符

更多/更少的分页符

我使用的是 Mac 操作系统。我有一个 C++ 程序,它生成 1000 多行数据,我将这些数据重定向到一个文件。然后我使用less/more来浏览该文件。我想less在用户定义的数据块处暂停,而不是暂停每个屏幕。我以为我可以使用该^L字符来标记分页符,但即使在我的 C++ 代码中添加它们之后

        printf("control-l \n");

我的 Mac 上的命令less仍然会在每个屏幕上暂停,而不是在每个 control-L 处暂停。

我记得几十年前这在 Unix 上是有效的。我需要在这里做一些不同的事情吗?

答案1

不是分页符,但可以设置“u”和“d”键来滚动屏幕,无论您想要多少行。默认情况下,按这些键会将文件“向上”和“向下”滚动半个屏幕。但是,如果您在按任一键之前键入数字,则两个键都会开始按您指定的行数滚动文件。

less file:
  10d ; scrolls the file down 10 lines
  d   ; scrolls the file down another 10 lines
  u   ; scrolls the file up 10 lines
  25d ; scrolls the file down 25 lines
  d   ; scrolls the file down 25 lines
  u   ; scrolls the file up 25 lines
  5u  ; scrolls the file up 5 lines
  d   ; scrolls the file down 5 lines

注意:我在 Debian Linux 上使用 GNU 版本的 less。 Mac 版本可能有所不同。

答案2

less不会在换页时暂停,但您可以通过以下方式达到相同的效果寻找对他们来说:/ CtrlV CtrlL Enter。按n可跳至下一个换页,或N返回上一个换页。

相关内容