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

  • 相关阅读:
    python 序列的方法
    python函数基础
    Flume入门:安装、部署
    Flume日志收集系统介绍
    Python 列表(List)操作方法详解
    在linux下新增一块硬盘的操作。(包含大于2T的硬盘在linux下挂载操作)
    python字符串操作大全
    Python中的迭代器漫谈
    Linux 常用快捷键
    ssh采用expect实现自动输入密码登录、拷贝
  • 原文地址:https://www.cnblogs.com/xuanbjut/p/11637359.html
Copyright © 2011-2022 走看看