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

  • 相关阅读:
    读书笔记之理想设计的特征
    一些javascript 变量声明的 疑惑
    LINQ 使用方法
    Google MySQL tool releases
    读书笔记之设计的层次
    EF之数据库连接问题The specified named connection is either not found in the configuration, not intended to be used with the Ent
    转载 什么是闭包
    javascript面向对象起步
    Tips
    数据结构在游戏中的应用
  • 原文地址:https://www.cnblogs.com/xuanbjut/p/11637359.html
Copyright © 2011-2022 走看看