• 一天一个 Linux 命令(15):more 命令


    一、简介

    Linux more 命令在我们查看文件的时候,可以一页一页的进行显示,逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会往回(back)一页显示,而且还有搜寻字串的功能(与 vi 相似),使用中的说明文件,按 h

    二、格式说明

    more [options] file...
    more [参数] 文件...
    
    Usage: more [options] file...
    
    Options:
      -d        display help instead of ring bell
      -f        count logical, rather than screen lines
      -l        suppress pause after form feed
      -p        do not scroll, clean screen and display text
      -c        do not scroll, display text and clean line ends
      -u        suppress underlining
      -s        squeeze multiple blank lines into one
      -NUM      specify the number of lines per screenful
      +NUM      display file beginning from line number NUM
      +/STRING  display file beginning from search string match
      -V        output version information and exit
    

    三、选项说明

    -d 提示使用者,在画面下方显示 [Press space to continue, 'q' to quit.] ,如果使用者按错键,则会显示 [Press 'h' for instructions.] 而不是 '哔' 声
    -f 计算行数时,以实际上的行数,而非自动换行过后的行数(有些单行字数太长的会被扩展为两行或两行以上)
    -l 取消遇见特殊字元 ^L(送纸字元)时会暂停的功能
    -p 不以卷动的方式显示每一页,而是先清除萤幕后再显示内容
    -c 跟 -p 相似,不同的是先显示内容再清除其他旧资料
    -u 不显示下引号 (根据环境变数 TERM 指定的 terminal 而有所不同)
    -s 当遇到有连续两行以上的空白行,就代换为一行的空白行
    +NUM 从第 num 行开始显示,如more +1 tree.txt 
    -NUM 一次显示的行数,more -1 tree.txt 
    +/STRING 在每个文档显示前搜寻该字串(STRING),然后从该字串之后开始显示
    
    fileNames 欲显示内容的文档,可为复数个数
    

    四、命令功能

    more命令和cat的功能一样都是查看文件里的内容,但有所不同的是more可以按页来查看文件的内容,还支持直接跳转行等功能。

    五、常见用法

    1.逐页显示 /var/log/messages文件内容

    more /var/log/messages
    

    2.从第 20 行开始显示 /var/log/messages文件内容。

    more +20 /var/log/messages
    

    3.设定每屏显示行数,每页只显示 /var/log/messages文件的5行内容

    more -5 /var/log/messages
    
     

    4.从/var/log/messages文件中查找第一个出现"systemd"字符串的行,并从该处前两行开始显示输出

    more +/systemd /var/log/messages
    

    5.逐页显示 /var/log/messages文件内容,如有连续两行以上空白行则以一行空白行显示。

    more -s /var/log/messages
    

    六、常用操作命令

    • 空格键 向下滚动一屏
    • Enter 向下n行,需要定义。默认为1行
    • Ctrl+F 向下滚动一屏
    • Ctrl+B 返回上一屏
    • = 输出当前行的行号
    • :f 输出文件名和当前行的行号
    • v 调用vi编辑器
    • !命令 调用Shell,并执行命令
    • q 退出more

     

  • 相关阅读:
    IEEE Bigger系列题解
    Codeforces Round #354 (Div. 2) E. The Last Fight Between Human and AI 数学
    Codeforces Round #354 (Div. 2) D. Theseus and labyrinth bfs
    Codeforces Round #354 (Div. 2) C. Vasya and String 二分
    Codeforces Round #354 (Div. 2) B. Pyramid of Glasses 模拟
    Codeforces Round #354 (Div. 2) A. Nicholas and Permutation 水题
    Codeforces Round #FF (Div. 1) B. DZY Loves Modification 优先队列
    Codeforces Round #FF (Div. 1) A. DZY Loves Sequences 动态规划
    2016 UESTC DP专题题解
    HDU 5701 中位数计数 暴力
  • 原文地址:https://www.cnblogs.com/joshua317/p/15307170.html
Copyright © 2020-2023  润新知