zoukankan      html  css  js  c++  java
  • linux下查看文件内容cat,more,less

    1. 查看文件内容经常使用的命令


    cat : 由第一行显示文件内容
    tac:  从最后一行開始显示。与cat相反
    nl :  文件内容和行号一起输出
    more: 一页一页显示
    less: 与more类似,能够往前翻页
    head: 取头部几行
    tail:  取尾部几行
    od: 以二进制方式读取文件内容

    2. cat命令


    查看cat的參数 cat --h
    $ cat --h
    Usage: cat [OPTION] [FILE]...
    Concatenate FILE(s), or standard input, to standard output.
    
      -A, --show-all           equivalent to -vET
                               与-vET等价
      -b, --number-nonblank    number nonblank output lines
                               输出行号,仅仅针对非空白行
      -e                       equivalent to -vE
                               与-vE等价
      -E, --show-ends          display $ at end of each line
                               文件末尾展示$
    
      -n, --number             number all output lines
                               输出行号
      -s, --squeeze-blank      never more than one single blank line
                               合并多个空白行,仅仅输出一行
      -t                       equivalent to -vT
      -T, --show-tabs          display TAB characters as ^I
                               将 TAB 展示为^I
      -v, --show-nonprinting   use ^ and M- notation, except for LFD and TAB
                               展示一些看不出来的字符
    $ cat 1
    hello   world
    
    
    hello   linux
    
    查看行号和特殊符号
    $ cat -n 1
         1  hello   world
         2
         3
         4  hello   linux
         5
    
    $ cat -A 1 
    hello^Iworld^M$
    ^M$
    ^M$
    hello^Ilinux^M$
    ^M$
    -A參数 结尾以 $结束, TAB 以^I展示。 ^M表示windiows下的回车键。

    cat一次全展示文件,当文件比較大时。来不及看就翻屏过了。
    推荐使用more或less来查看文件。

    3. more命令


    more可翻页查看。

    $ more filename
    经常使用命令:
    空格 space : 向下翻页
    Enter :           向下滚动一行
    /字符串 :       向下查询字符串
    :f  :                 显示当前行号
    q :                 退出
    b :                 往回翻页。仅仅在文件有作用。对管道无作用。

    4. less命令


    less也是一页一页的查看,与more不同的是能够向上翻页
    $ less filename
    经常使用命令:
    空格 space :          向下翻一页
    Enter :                     向下一行
    [PageDown] :        向下一页:
    [PageUp] :             向上一页
    /字符串:                  向下查询
    ?

    字符串:                向上查询

    n :                           反复前一个查询 / 或 ?
    N :                          反向前一个查询 / 或 ?

    q :                           退出

    less的參数与man命令的參数类似,由于man命令就是调用less显示说明文档的。





  • 相关阅读:
    HDU 1495 非常可乐
    ja
    Codeforces Good Bye 2016 E. New Year and Old Subsequence
    The 2019 Asia Nanchang First Round Online Programming Contest
    Educational Codeforces Round 72 (Rated for Div. 2)
    Codeforces Round #583 (Div. 1 + Div. 2, based on Olympiad of Metropolises)
    AtCoder Regular Contest 102
    AtCoder Regular Contest 103
    POJ1741 Tree(点分治)
    洛谷P2634 [国家集训队]聪聪可可(点分治)
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/5204747.html
Copyright © 2011-2022 走看看