Linux difference in more, less, and most of

If you are a novice Linux area, you may be wondering between more, less, most of the three command-line tool. In this article, when I have these three command-line tool to compare and show some examples of their respective use in Linux. In general, these orders are similarities and differences between line tools, and they have built on most Linux distributions.

We first take a look at the more command.

more command

is a more old-fashioned, terminal-based paging reader, which can be used to open a specified file and interactive reading. If the contents of the file is too long to complete within a display screen, page by page will display the contents of the file. Use the Enter key or the spacebar to scroll browse the contents of the file, but there is a limit, which is only capable of one-way scrolling. That can only order page down, but can not look back.

correct

Some Linux users pointed out to me, the more of them can flip up. However, most of the original version only allowed to page down more indeed, in the subsequent emergence of a newer version of the page up also allows a limited number, just press the b key to page up during browsing. The only restriction is more with the pipeline can not use (such as ls | more). (LCTT Translation: the original author of suspected wrong here, use more translators can be used with pipes, and perhaps more relevant to different versions)

Press q to exit more.

More examples

Open the file ostechnix.txt interactive reading, you can execute the following command:

$ more ostechnix.txt

In the reading process, if you need to find a string that simply do enter a slash like this (/) and then enter the following content you want:

/linux

Press n jump to the next string matching.

If you need to start reading at line 10 of file, simply execute:

$ more +10 file

We can begin to display the contents of a file from line 10 of the file.

If you need to get more tips you press the space bar to turn pages, you can add -d parameter:

$ more -d ostechnix.txt

As shown, more will prompt the above chart you can press the space bar to turn pages.

If you want to see all the options and the corresponding buttons, you can press the h key.

To view more detailed information about more, refer to the manual:

$ man more

less command

less command is used to open a specified file and interactive reading, it also supports page and search. If the contents of the file is too long, the output will be paged, and therefore can page read. More than the command Even better, less support page up and page down, that can be read in any entire file.

In function, less than more command has more advantages, some of which are listed below:

  • Support Page Up and Page Down
  • Support search and search up down
  • You can jump to the end of the file and immediately start reading from the beginning of the file
  • Open the specified file in the editor

More examples

open a file:

$ less ostechnix.txt

Press the spacebar or Enter key to scroll down, page up key press b.

To search down, after the input slash (/) and then enter the contents to be searched:

/linux

Press n jump to the next string matching, if the need to jump to a matching string can press the N key.

(?) If you need to search up, enter a question mark after then enter the content to be searched:

?linux

Likewise Press n or N jumps to the next or previous string matching.

Simply press v key, they will be're reading the file opens in the default editor, and then you can file for a variety of editing operations.

Press h key to view less tool options and the corresponding key.

Press the q key to quit reading.

To see more details less, refer to the manual:

$ man less

most command

most terminal is also a reading tool, and more and more abundant than less functionality. most support open multiple files. You can switch between open files, edit the current open files, quickly jump to a line in the file, split-screen reading, or scroll through multiple screens simultaneously locking and more. By default, for long lines, most are not truncated into multiple lines, but to provide a function to display scrolling left and right in the same row.

More examples

open a file:

$ most ostechnix1.txt

Press the e key to edit the current file.

To search down in slash (/) after the contents of the input or S, or f to be searched, press n can jump to the next string matching.

After typing in search requires a search direction if desired, the question mark (?), Is a matching string by n to jump to the next.

Open multiple files:

$ most ostechnix1.txt ostechnix2.txt ostechnix3.txt

在打开了多个文件的状态下,可以输入 :n 切换到下一个文件,使用 ↑ 或 ↓ 键选择需要切换到的文件,按回车键就可以查看对应的文件。

要打开文件并跳转到某个字符串首次出现的位置(例如 linux),可以执行以下命令:

$ most file +/linux

按 h 键可以查看帮助。

按键操作列表

移动:

  • 空格键或 D 键 – 向下滚动一屏
  • DELETE 键或 U 键 – 向上滚动一屏
  • ↓ 键 – 向下移动一行
  • ↑ 键 – 向上移动一行
  • T 键 – 移动到文件开头
  • B 键 – 移动到文件末尾
  • > 键或 TAB 键 – 向右滚动屏幕
  • < 键 – 向左滚动屏幕
  • → 键 – 向右移动一列
  • ← 键 – 向左移动一列
  • J 键或 G 键 – 移动到某一行,例如 10j 可以移动到第 10 行
  • % 键 – 移动到文件长度某个百分比的位置

窗口命令:

  • Ctrl-X 2、Ctrl-W 2 – 分屏
  • Ctrl-X 1、Ctrl-W 1 – 只显示一个窗口
  • O 键、Ctrl-X O – 切换到另一个窗口
  • Ctrl-X 0 – 删除窗口

文件内搜索:

  • S 键或 f 键或 / 键 – 向下搜索
  • ? 键 – 向上搜索
  • n 键 – 跳转到下一个匹配的字符串

退出:

  • q 键 – 退出 most ,且所有打开的文件都会被关闭
  • :N、:n – 退出当前文件并查看下一个文件(使用 ↑ 键、↓ 键选择下一个文件)

要查看 most 的更多详细信息,可以参考手册:

$ man most

总结

more – 传统且基础的分页阅读工具,仅支持向下翻页和有限次数的向上翻页。

less – 比 more 功能丰富,支持向下翻页和向上翻页,也支持文本搜索。在打开大文件的时候,比 vi 这类文本编辑器启动得更快。

most – 在上述两个工具功能的基础上,还加入了同时打开多个文件、同时锁定或滚动多个屏幕、分屏等等大量功能。

以上就是我的介绍,希望能让你通过我的文章对这三个工具有一定的认识。如果想了解这篇文章以外的关于这几个工具的详细功能,请参阅它们的 man 手册。

您可能感兴趣的文章:

文章同步发布: https://www.geek-share.com/detail/2769911793.html

Guess you like

Origin www.cnblogs.com/xiaoqifeng/p/10930201.html
Recommended