文章目录
1. more 命令说明
more:分页查看文件内容,还有很多快捷键可用。基本信息如下:
DESCRIPTION
More is a filter for paging through text one screenful at a time. This version is especially primitive. Users should realize that
less(1) provides more(1) emulation and extensive enhancements.
OPTIONS
Command line options are described below. Options are also taken from the environment variable MORE (make sure to precede them with a
dash (‘‘-’’)) but command line options will override them.
-num This option specifies an integer which is the screen size (in lines).
-d more will prompt the user with the message "[Press space to continue, ’q’ to quit.]" and will display "[Press ’h’ for instruc-
tions.]" instead of ringing the bell when an illegal key is pressed.
-l more usually treats ^L (form feed) as a special character, and will pause after any line that contains a form feed. The -l option
will prevent this behavior.
-f Causes more to count logical, rather than screen lines (i.e., long lines are not folded).
-p Do not scroll. Instead, clear the whole screen and then display the text.
-c Do not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.
-s Squeeze multiple blank lines into one.
-u Suppress underlining.
+/ The +/ option specifies a string that will be searched for before each file is displayed.
+num Start at line number num.
参数如下:
选项 | 作用 |
---|---|
-num | 每页按照num行显示 |
-d | 提示“Press space to continue,’q’ to quit(按空格键继续,按q键退出)” |
-l | 忽略Ctrl+l(换页)字符 |
-f | 计算行数时,以实际上的行数,而非自动换行过后的行数 (有些单行字数太长的会被扩展为两行或两行以上) |
-p | 不以滚动的方式显示每一页,而是先清除萤幕后再显示内容 |
-c | 与 -p 相似 |
-s | 把连续的多个空行显示为一行 |
-u | 把文件内容中的下画线去掉 |
+num | 从num行开始显示 |
+/pattern | 从文件中匹配该字串(pattern),然后从该字串前两行之后开始显示 |
2. more 命令语法
more [选项] 文件
3. more 命令示例
3.1 不加参数
不加参数时,会按照当前屏幕显示文件内容
more 文件
3.2 -num(定义每页行数)
默认是显示一个屏幕的,-num 可以自定义每页显示的行数。
举例:每页5行显示
more -5 文件
3.3 +num(从num行开始)
举例:从第二十行开始显示
more +20 文件
3.4 +/pattern(匹配显示)
pattern 代表要寻找的字符串,匹配上后,从匹配到的前两行开始显示。若匹配不到会显示“Pattern not found”
举例:寻找字符串-10
more +/10 文件
3.5 快捷键
more 命令执行之后有很多快捷键可用,部分如下:
操作 | 说明 |
---|---|
空格键 | 向下翻一页 |
Enter | 向下翻一行 |
b | 向上翻一页 |
f | 向下翻一页 |
q | 退出 more |
= | 显示当前行号 |
:f | 显示文件名和当前行的行号 |
!命令 | 执行命令 |
V | 进入 vi 编辑文件 |
/pattern | 匹配字符串 |
4. 总结
more 可分页显示文件内容,与 cat 相比,more 的功能更强大,适合查看大文件,并且有很多快捷键可用。