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.

tail 显示文件内容尾部的更多相关文章

  1. linux命令 显示文件内容

    通过命令+文件名查看内容.如下命令可以查看.1, cat :由第一行开始显示文件内容:2,tac:从最后一行开始显示,可以看出tac与cat字母顺序相反:3,nl:显示的时候输出行号:4,more:一 ...

  2. 解决gitk显示文件内容中文乱码

    解决gitk显示文件内容中文乱码 1.git config 命令 设置git gui的界面编码 git config --global gui.encoding utf-8 2.修改配置文件 在~\e ...

  3. Python easyGUI 文件浏览 显示文件内容

    #提供一个文件浏览夹.让用户选择需要打开的文件,打开并显示文件内容: import easygui as g import os msg='浏览文件并打开' title='测试' default='D ...

  4. less 分页显示文件内容

    1.命令功能 less 是more的增强版,可以分页显示文件内容,而且less打开文件的速度要比vi,more更快.less支持搜索功能,显示行号. 2.语法格式 less  option  file ...

  5. more 分页显示文件内容

    1.命令功能 more 分页显示文件内容 2.语法格式 more  option file 参数说明 参数 参数说明 -num 指定屏幕显示大小为num行 +num 从行号num号开始显示 -s 把连 ...

  6. tac反向显示文件内容

    1.命令功能 tac是cat的反向拼写功能是反向显示文件内容.cat是从文件第一行开始读取文件输出,tac是从最后一行开始读取文件并进行反向输出. 2.语法格式 tac  [option]  [fil ...

  7. tac 反向显示文件内容

    1.命令功能 tac是cat的反向拼写,功能是反向显示文件内容. 2.语法格式 tac  option  file 3.使用范例 [root@localhost chu]# cat test.txt ...

  8. tail 显示文件最后若干行内容

    功能:tail命令可以输出文件的尾部内容,默认情况下它显示文件的最后十行.显示每个指定文件的最后10 行到标准输出.若指定了多于一个文件,程序会在每段输出的开始添加相应文件名作为头.如果不指定文件或文 ...

  9. linux命令显示文件内容行号|linux将内容以行号显示出来

            查看文件内容:cat /etc/shadow里面所有内容         cat命令是全部输出          cat /etc/shadow -n 输出内容及行号,空行业输出了   ...

随机推荐

  1. CodeForces - 474D (dp)

    题目:https://vjudge.net/contest/326867#problem/B 题意:有很多个蛋糕,现在你有两种吃蛋糕的吃法,一次吃一个,定为A,一次吃k个定为B,然后问你吃m个蛋糕有多 ...

  2. Linux相关基础知识

    文件目录 /bin 放置系统执行档的目录,指令可被root与一般账户所使用. /boot 放置开机使用到的文档,包括linux核心档案,开机选单与所需设定档. /dev 任何装置与周边设备都是以档案的 ...

  3. [CSP-S模拟测试]:排列组合(数学 or 找规律)

    题目描述 $T$组数据,每次给定$n$,请求出下式的值,对$10^9+7$取模: $$C_n^0\times C_n^0+C_n^1\times C_n^1+C_n^2\times C_n^2+... ...

  4. 《SQL Server 2012 T-SQL基础》读书笔记 - 6.集合运算

    Chapter 6 Set Operators 语法如下: Input Query1 <set_operator> Input Query2 [ORDER BY ...] 有ORDER B ...

  5. zk的KeeperErrorCode = ConnectionLoss错误

    额,这东西都快把人搞崩溃了,各种排查各种正常. 最后竟然是因为我在客户端未连接上zkserver的时候就进行了create操作造成的错误. 噗, Exception in thread "m ...

  6. anaconda 下载包速度慢

    更新清华镜像资源 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda ...

  7. How To Use the Widget Factory 使用widget factory创建插件

    To start, we'll create a progress bar that just lets us set the progress once.  创建一个基于widget factory ...

  8. 【洛谷P1036 选数】

    这个题显然用到了深搜的内容 让我们跟着代码找思路 #include<bits/stdc++.h>//万能头 ],ans; inline bool prime(int n)//最简单的判定素 ...

  9. 011-elasticsearch5.4.3【四】-聚合操作【二】-桶聚合【bucket】过滤、嵌套、反转、分组、排序、范围

    一.概述 bucketing(桶)聚合:划分不同的“桶”,将数据分配到不同的“桶”里.非常类似sql中的group语句的含义. metric既可以作用在整个数据集上,也可以作为bucketing的子聚 ...

  10. seaborn

    Seaborn是基于matplotlib的Python数据可视化库. 它提供了一个高级界面,用于绘制引人入胜且内容丰富的统计图形. 一  风格及调色盘 风格 1 sns.set()  模式格式 2 s ...