Linux zmore 初学者命令教程(5 个示例)Linux zmore 初学者命令教程(5 个示例)Linux zmore 初学者命令教程(5 个示例)Linux zmore 初学者命令教程(5 个示例)
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

Linux zmore 初学者命令教程(5 个示例)

在此页

  1. Linux zmore 命令
  2. Q1。如何使用zmore?
  3. Q2。如何使 zmore 滚动文件内容一次多行?
  4. Q3。如何制作 zmore 跳线或屏幕?
  5. Q4。如何让zmore显示当前行号?
  6. Q5。 zmore如何判断终端特性?
  7. 结论

有时,您可能想查看压缩文件的内容而不先解压缩它。好吧,您会很高兴知道 Linux 提供了一个命令行实用程序来让您执行此操作。在本教程中,我们将使用一些易于理解的示例来讨论 zmore 命令的基础知识。

但在我们这样做之前,值得一提的是,这里的所有示例都已经在 Ubuntu 18.04 LTS 机器上进行了测试。

Linux zmore 命令

Linux 中的 zmore 命令基本上是一个用于 crt 查看压缩文本的文件细读过滤器。以下是它的语法:

zmore [ name ...  ]

工具手册页是如何定义它的:

Zmore  is  a  filter  which  allows  examination of compressed or plain text files one screenful 
at a time on a soft-copy terminal. Zmore works on files compressed with compress, pack or gzip,
and also on uncompressed files.  If a file does not exist, zmore looks for a file of the same name
with the addition of a .gz, .z or .Z suffix.

Zmore  normally  pauses  after  each  screenful,  printing --More-- at the bottom of the screen. 
If the user then types a carriage return, one more line is displayed. If the user hits a space,
another screenful is displayed.  Other possibilities are  enumerated later.

以下是一些 Q&A 风格的示例,它们可以让您更好地了解 zmore 命令的工作原理。

Q1。如何使用zmore?

假设您有一个压缩文件 - 在我的例子中是 test.html.gz - 您希望在终端屏幕上一次快速查看一页或一行的内容。以下是如何使用 zmore 执行此操作:

zmore test.html.gz

上述命令产生了以下输出:

所以你可以看到文件的第一页是在输出中生成的。您可以按 enter 键一次一行地滚动和查看文件的其余部分。要退出,请按 q。

Q2。如何使 zmore 滚动文件内容一次多行?

当然,多次按下回车键是一种方式,但绝对不是优雅的方式。一种更好的方法是按空格键,这样您就可以一次滚动一个屏幕。

但是,如果您想一次滚动多行内容,只需按 i 后跟一个表示要滚动的行数的数字。

i<space>
              display i more lines, (or another screenful if no argument is given)

或者,您也可以按 Ctrl+D 使 zmore 多显示 11 行。

^D     display 11 more lines (a ``scroll'').  If i is given, then the scroll size is set to i.

Q3.如何制作 zmore 跳线或屏幕?

zmore 命令为此提供了两个选项:

is - skip i lines and print a screenful of lines

if - skip i screenfuls and print a screenful of lines

Q4.如何让zmore显示当前行号?

在使用 zmore 的任何时间点,如果您想知道当前行号,只需按 =。

例如,在我的例子中,当我按下=时,zmore 在屏幕底部显示 35。

Q5. zmore如何判断终端特性?

这是通过文件 /etc/termcap 完成的。手册页详细解释了它:

Zmore looks in the file /etc/termcap to determine terminal characteristics, and to determine the 
default window size. On a terminal capable of displaying 24 lines, the default window size is 22
lines. To use a pager other than the default more, set  environment variable PAGER to the name of
the desired program, such as less.

要更改窗口大小,请使用 iz 方法。这是它的解释:

iz  -   same as typing a space except that i, if present, becomes the new window size.

结论

zmore 命令对于那些经常处理压缩文件的人来说很方便。该工具的学习曲线并不陡峭。我们已经讨论了 zmore 提供的一些有用的命令行选项。要了解更多信息,请访问工具手册页。

©2015-2025 艾丽卡 support@alaica.com