zoukankan      html  css  js  c++  java
  • 2.5. 查看文件内容

    2.5. 查看文件内容

    查看文件:cat vi head tail more

    显示时同时显示行号:

    $cat -n
    

    按页显示列表内容:

    $ls -al | more
    

    只看前10行:

    $head - 10 **
    

    显示文件第一行:

    $head -1 filename
    

    显示文件倒数第五行:

    $tail -5 filename
    

    查看两个文件间的差别:

    $diff file1 file2
    

    动态显示文本最新信息:

    $tail -f crawler.log

    # tail -10 ndm
    818 [ 42.028236] virbr0: port 1(virbr0-nic) entered blocking state
    819 [ 42.028241] virbr0: port 1(virbr0-nic) entered listening state
    820 [ 42.028282] IPv6: ADDRCONF(NETDEV_UP): virbr0: link is not ready
    821 [ 42.060817] virbr0: port 1(virbr0-nic) entered disabled state
    822 [ 463.502594] r8169 0000:02:00.0 enp3s0: link up
    823 [ 463.502608] IPv6: ADDRCONF(NETDEV_CHANGE): enp3s0: link becomes ready
    824 [ 480.659625] fuse init (API version 7.22)
    825 [ 493.708782] TCP: lp registered
    826 [ 3366.229811] ipmi message handler version 39.2
    827 [ 3366.231122] ipmi device interface
    [root@linux72 yix]# head -10 ndm
    1 [ 0.000000] microcode: microcode updated early to revision 0x20, date = 2018-04-10
    2 [ 0.000000] Initializing cgroup subsys cpuset
    3 [ 0.000000] Initializing cgroup subsys cpu
    4 [ 0.000000] Initializing cgroup subsys cpuacct
    5 [ 0.000000] Linux version 3.10.0-957.el7.x86_64 (mockbuild@kojibuilder-ve) (gcc version 4.8.5 20150623 (NeoKylin 4.8.5-36) (GCC) ) #1 SMP Fri Jan 11 17:34:50 CST 2019
    6 [ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/nlas-root ro crashkernel=auto rd.lvm.lv=nlas/root rd.lvm.lv=nlas/swap rhgb quiet LANG=zh_CN.UTF-8
    7 [ 0.000000] e820: BIOS-provided physical RAM map:
    8 [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009d7ff] usable
    9 [ 0.000000] BIOS-e820: [mem 0x000000000009d800-0x000000000009ffff] reserved
    10 [ 0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
    [root@linux72 yix]#

    # head -1 ndm
    1 [ 0.000000] microcode: microcode updated early to revision 0x20, date = 2018-04-10

    # tail -1 ndm
    827 [ 3366.231122] ipmi device interface

    # cat -n dmes 

    1 [ 0.000000] microcode: microcode updated early to revision 0x20, date = 2018-04-10
    2 [ 0.000000] Initializing cgroup subsys cpuset
    3 [ 0.000000] Initializing cgroup subsys cpu
    4 [ 0.000000] Initializing cgroup subsys cpuacct
    5 [ 0.000000] Linux version 3.10.0-957.el7.x86_64 (mockbuild@kojibuilder-ve) (gcc version 4.8.5 20150623 (NeoKylin 4.8.5-36) (GCC) ) #1 SMP Fri Jan 11 17:34:50 CST 2019
    6 [ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/nlas-root ro crashkernel=auto rd.lvm.lv=nlas/root rd.lvm.lv=nl

  • 相关阅读:
    创建桌面快捷方式
    令牌桶在数据通信QoS流量监管中的应用
    cocos2d-x 实现clash of clans多点聚焦缩放场景
    NotePad++ 快捷键中文说明
    2017第24周日
    《自信力~成为更好的自己》晨读笔记
    不知道如何决定的时候就快速决定
    《意外之外》晨读笔记
    《从“为什么”开始》听书笔记
    解决电脑上网问题记录
  • 原文地址:https://www.cnblogs.com/xuanbjut/p/11637359.html
Copyright © 2011-2022 走看看