Linux基础命令[14]-more

本文详细介绍了more命令的用法,包括基本说明、自定义每页行数、从特定行开始、搜索模式以及丰富的快捷键。more作为查看大文件的强大工具,提供了比cat更灵活的体验。
摘要由CSDN通过智能技术生成

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 的功能更强大,适合查看大文件,并且有很多快捷键可用。

  • 13
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值