zoukankan      html  css  js  c++  java
  • 每天一个linux命令(12):more命令

    1、命令简介

    more (more) 该命令一次显示一屏文本,满屏后停下来,并且在屏幕的底部出现一个提示信息,给出至今己显示的该文件的百分比,方便逐页阅读(file perusal filter for crt viewing) 。more名单中内置了若干快捷键,按空白键(space)就往下一页显示,按 b 键就会往回(back)一页显示,而且还有搜寻字串的功能(与 vi 相似),使用中按h可以查看说明文件 。

    2、用法

    more [-dlfpcsu] [-num] [+/pattern] [+linenum] [fileNames..]

    3、选项

    参数:
    - num 一次显示的行数
    -d 提示使用者,在画面下方显示 [Press space to continue, 'q' to quit.] 如果按错键,则会显示 [Press 'h' for instructions.] 而不是 ''
    -l 取消遇见特殊字元 ^L(送纸字元)时会暂停的功能 忽略Ctrl+l(换页)字符
    - f 计算行数时,以实际上的行数,而非自动换行过后的行数(有些单行字数太长的会被扩展为两行或两行以上)
    - p 不以卷动的方式显示每一页,而是先清除萤幕后再显示内容-c 跟 -p 相似,不同的是先显示内容再清除其他旧资料
    -s  squeese 当遇到有连续两行以上的空白行,就代换为一行的空白行
    -u 不显示下引号 (根据环境变数 TERM 指定的 terminal 而有所不同)
    +/ 在每个档案显示前搜寻该字串(pattern),然后从该字串之后开始显示
    +num 从第 num 行开始显示
    fileNames 欲显示内容的档案,可为复数个数
    more以后可以使用的操作命令(按h 弹出)
    -------------------------------------------------------------------------------
    空格键                     向下滚动一屏
    z                       Display next k lines of text [current screen size]*
    <return>                   Display next k lines of text [1]*
    d or ctrl-D               Scroll k lines [current scroll size, initially 11]*
    q or Q or <interrupt>   退出more
    s                       Skip forward k lines of text [1]
    f                       Skip forward k screenfuls of text [1]
    b or ctrl-B             返回上一屏
    '                       跳转到上次查找开始的位置
    =                       输出当前行的行号
    /
    模式                      查找符合模式的内容,按n为下一个,N为上一个
    n                       Search for kth occurrence of last r.e [1]
      !命令 or :! 命令             调用Shell,并执行命令
      v                       调用vi
      ctrl
    -L                  Redraw screen
      :n                      Go to kth next
    file [1]
      :p                      Go to kth previous
    file [1]
      :f                      输出文件名和当前行的行号
      .                       执行上一个命令
    -------------------------------------------------------------------------------

    4、示例

    1、显示文件file的内容,但在显示之前先清屏,并且在屏幕的最下方显示完核的百分比。
    [root@oracledb log]# more -dc boot.log
    2、每次显示5行
    [root@oracledb log]# more -5 boot.log 
            Welcome to CentOS 
    Starting udev:                                             [  OK  ]
    Setting hostname oracledb:                                 [  OK  ]
    Setting up Logical Volume Management:                      [  OK  ]
    Checking filesystems
    
    --More--(9%)

    按空格键显示5-10行,不清屏

    [root@oracledb log]# more -5 boot.log 
            Welcome to CentOS 
    Starting udev:                                             [  OK  ]
    Setting hostname oracledb:                                 [  OK  ]
    Setting up Logical Volume Management:                      [  OK  ]
    Checking filesystems
    /dev/sda3: clean, 167181/6152192 files, 4828976/24590080 blocks
    /dev/sda1: clean, 51/51200 files, 103880/204800 blocks
                                                               [  OK  ]
    Remounting root filesystem in read-write mode:             [  OK  ]
    Mounting local filesystems:                                [  OK  ]
    
    --More--(21%)
    3、每次显示5行,清屏显示
    [root@oracledb log]# more -p -5 boot.log 
            Welcome to CentOS 
    Starting udev:                                             [  OK  ]
    Setting hostname oracledb:                                 [  OK  ]
    Setting up Logical Volume Management:                      [  OK  ]
    Checking filesystems
    --More--(9%)

    按空格

    /dev/sda3: clean, 167181/6152192 files, 4828976/24590080 blocks
    /dev/sda1: clean, 51/51200 files, 103880/204800 blocks
                                                               [  OK  ]
    Remounting root filesystem in read-write mode:             [  OK  ]
    Mounting local filesystems:                                [  OK  ]
    --More--(21%)
    4、more +10 filename 从第 10 行开始显示 file之档案内容。
    [root@oracledb log]# more +10 boot.log 
    Mounting local filesystems:                                [  OK  ]
    Enabling local filesystem quotas:                          [  OK  ]
    Enabling /etc/fstab swaps:                                 [  OK  ]
    5、more -s file 逐页显示 testfile 之档案内容,如有连续两行以上空白行则以一行空白行显示。
    [root@oracledb study]# more -s test.log 
    2016
    2017
    
    2018前面有两空行

    6、more进行中!执行命令

    !ifconfig
    eth5      Link encap:Ethernet  HWaddr 08:00:27:60:11:C4  
              inet addr:172.17.22.31  Bcast:172.17.23.255  Mask:255.255.254.0
              inet6 addr: fe80::a00:27ff:fe60:11c4/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:13261006 errors:0 dropped:0 overruns:0 frame:0
              TX packets:55082 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:941658780 (898.0 MiB)  TX bytes:5059734 (4.8 MiB)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:16 errors:0 dropped:0 overruns:0 frame:0
              TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:1584 (1.5 KiB)  TX bytes:1584 (1.5 KiB)
    
    ------------------------
    --More--(9%)
    7、根据模式查找字符串,输入斜杠 /模式字符串 回车进行查找,n和N控制向上和向下查找
    # Mandatory: no
    # Range: 60-3600
    # 上面为more的显示内容
    
    /Hostname=Zabbix server

    查找出的结果在最上面显示

    ...skipping
    # Hostname=
    
    Hostname=Zabbix server
    
    ### Option: HostnameItem
    #    Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.
    #    Does not support UserParameters or aliases.
  • 相关阅读:
    【Java】增强的for流程
    xxxxx
    lyphtesttest rename of file
    lyphtesttest winmerge class の比較
    lyphtesttest sql of system session
    lyphtesttest 常用ファイルの操作、検索。excelの操作  java
    Maven3(2.集成maven插件到eclipse(包含eclipse安装svn步骤))
    Maven3(1.下载maven安装与配置)
    centos6 安装hbase+hadoop单机版
    centos6 安装jdk1.6
  • 原文地址:https://www.cnblogs.com/xqzt/p/5414814.html
Copyright © 2011-2022 走看看