more命令使用说明

1、命令概述

more命令用于将内容较长的文本文件内容(不能在一屏显示完)进行分屏显示,并且支持在显示时定位关键字。而对于内容较少的文本文件内容则推荐使用cat命令查看。

2、命令语法

more 【选项】 【文件】 

3、命令选项

-num 指定每屏显示num行

+num 从第 num 行开始显示

+/pattern 在每个文档显示前搜寻该字(pattern),然后从该字串前两行之后开始显示

-l 取消遇见特殊字元 ^L(送纸字元)时会暂停的功能

-f 计算实际的行数,而非自动换行的行数(有些单行字数太长的会被扩展为两行或两行以上)

-p 先清除屏幕再显示文本文件的剩余内容

-c 与-p相似,不滚屏,先显示内容再清除旧内容

-s 多个空行压缩成一行显示

-u 不显示下划线

-d 提示“Press space to continue,’q’ to quit(按空格键继续,按q键退出)”,禁用响铃功能

命令内部操作:

    Space键:显示文本的下一屏内容
    Enter键:向下n行,需要定义,默认为1行
    q键:退出more命令
    Ctrl+f:向下滚动一屏
    Ctrl+b:返回上一屏
    =: 输出当前的行号
    :f:输出文件名和当前的行号
    v:调用vi编辑器
    !:调用Shell,并执行命令
    h:显示帮助屏

4、命令示例

4.1 -num 指定每屏显示num行,more -10 /etc/ssh/sshd_config     每屏显示10行

 1 [root@localhost ~]# more -10 /etc/ssh/sshd_config
 2 #    $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
 3 
 4 # This is the sshd server system-wide configuration file.  See
 5 # sshd_config(5) for more information.
 6 
 7 # This sshd was compiled with PATH=/usr/local/bin:/usr/bin
 8 
 9 # The strategy used for options in the default sshd_config shipped with
10 # OpenSSH is to specify options with their default value where
11 # possible, but leave them commented.  Uncommented options override the
12 --More--(11%)

4.2 +num 从第 num 行开始显示,more + 10 /etc/ssh/sshd_config    从第10行开始显示

4.3 +/pattern 在每个文档显示前搜寻该字(pattern),然后从该字串之后开始显示;more +/Port /etc/ssh/sshd_config   从包含Port字符的前两行开始显示

 1 [root@localhost ~]# more +/Port /etc/ssh/sshd_config
 2 
 3 ...跳过
 4 # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
 5 #
 6 Port 28256
 7 #AddressFamily any
 8 #ListenAddress 0.0.0.0
 9 #ListenAddress ::
10 
11 HostKey /etc/ssh/ssh_host_rsa_key
12 #HostKey /etc/ssh/ssh_host_dsa_key
13 HostKey /etc/ssh/ssh_host_ecdsa_key
14 HostKey /etc/ssh/ssh_host_ed25519_key
15 
16 # Ciphers and keying
17 #RekeyLimit default none

4.4 从文件中查找第一个出现"abc"字符串的行,并从该行前两行开始到最后一行输出为新文件

1 [root@localhost ~]# more +/abc work.txt > work1.txt

猜你喜欢

转载自www.cnblogs.com/liuzgg/p/11654027.html