zoukankan      html  css  js  c++  java
  • tail 显示文件内容尾部

    1.命令功能

    tail默认显示文件内容尾部10行。

    2.语法格式

    tail  option  file

    参数说明

    参数

    参数说明

    -n

    显示指定行数

    -f

    实时输出文件变化后追加的数据

    -s

    监视文件变化的间隔秒数

    -v

    总是显示包含指定文件名的文件头

    3.使用范例

    范例1  tail 默认显示后10行

    [root@localhost chu]# tail passwd
    
    nobody:x:99:99:Nobody:/:/sbin/nologin
    
    vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
    
    saslauth:x:499:76:Saslauthd user:/var/empty/saslauth:/sbin/nologin
    
    postfix:x:89:89::/var/spool/postfix:/sbin/nologin
    
    sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
    
    ntp:x:38:38::/etc/ntp:/sbin/nologin
    
    cxf:x:500:500::/home/cxf:/bin/bash
    
    ok:x:501:501::/home/ok:/bin/bash
    
    joe:x:502:502::/home/joe:/bin/bash
    
    chu:x:503:503::/home/chu:/bin/bash

    范例2  实时监控文件变化追加的内容

    [root@localhost chu]# tail -f /var/log/messages
    
    Apr 23 14:47:22 localhost sshd[1309]: Server listening on :: port 22.
    
    Apr 23 14:47:22 localhost xinetd[1320]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
    
    Apr 23 14:47:22 localhost xinetd[1320]: Started working: 1 available service
    
    Apr 23 14:47:24 localhost sshd[1436]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
    
    Apr 23 14:47:24 localhost sshd[1436]: error: Bind to port 22 on :: failed: Address already in use.

    范例3  显示文件头部

    [root@localhost chu]# tail -vf /var/log/messages
    
    ==> /var/log/messages <==
    
    Apr 23 14:47:22 localhost sshd[1309]: Server listening on :: port 22.
    
    Apr 23 14:47:22 localhost xinetd[1320]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
    
    Apr 23 14:47:22 localhost xinetd[1320]: Started working: 1 available service
    
    Apr 23 14:47:24 localhost sshd[1436]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
    
    Apr 23 14:47:24 localhost sshd[1436]: error: Bind to port 22 on :: failed: Address already in use.
  • 相关阅读:
    爱情三十七课,恩情仪式
    爱情三十二课,幽默的用法
    爱情四十二课,距离就是问题
    爱情二十八课,你为什么爱
    爱情三十四课,放手的时机
    爱情三十九课,爱的礼物
    爱情三十三课,读懂愤怒
    爱情三十一课,先信自己
    爱情三十课,爱情整理术
    爱情二十四课,妥协50分
  • 原文地址:https://www.cnblogs.com/joechu/p/8947454.html
Copyright © 2011-2022 走看看