linux文件目录操作命令 tail
来源:互联网 发布:apache源码包下载地址 编辑:程序博客网 时间:2024/06/15 02:11
1.命令格式;
tail[必要参数][选择参数][文件]
2.命令功能:
用于显示指定文件末尾内容,不指定文件时,作为输入信息进行处理。常用查看日志文件。
3.命令参数:
-f 循环读取
-q 不显示处理信息
-v 显示详细的处理信息
-c<数目> 显示的字节数
-n<行数> 显示行数
--pid=PID 与-f合用,表示在进程ID,PID死掉之后结束.
-q, --quiet, --silent 从不输出给出文件名的首部
-s, --sleep-interval=S 与-f合用,表示在每次反复的间隔休眠S秒
4.使用实例:
实例1:显示文件末尾内容
命令:
tail -n 5 log2014.log
输出:
[root@localhost test]# tail -n 5 log2014.log
2014-09
2014-10
2014-11
2014-12
==============================[root@localhost test]#
说明:
显示文件最后5行内容
实例2:循环查看文件内容
命令:
tail -f test.log
输出:
[root@localhost ~]# ping 192.168.120.204 > test.log &
[1] 11891[root@localhost ~]# tail -f test.log
PING 192.168.120.204 (192.168.120.204) 56(84) bytes of data.
64 bytes from 192.168.120.204: icmp_seq=1 ttl=64 time=0.038 ms
64 bytes from 192.168.120.204: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 192.168.120.204: icmp_seq=3 ttl=64 time=0.033 ms
64 bytes from 192.168.120.204: icmp_seq=4 ttl=64 time=0.027 ms
64 bytes from 192.168.120.204: icmp_seq=5 ttl=64 time=0.032 ms
64 bytes from 192.168.120.204: icmp_seq=6 ttl=64 time=0.026 ms
64 bytes from 192.168.120.204: icmp_seq=7 ttl=64 time=0.030 ms
64 bytes from 192.168.120.204: icmp_seq=8 ttl=64 time=0.029 ms
64 bytes from 192.168.120.204: icmp_seq=9 ttl=64 time=0.044 ms
64 bytes from 192.168.120.204: icmp_seq=10 ttl=64 time=0.033 ms
64 bytes from 192.168.120.204: icmp_seq=11 ttl=64 time=0.027 ms
[root@localhost ~]#
说明:
ping 192.168.120.204 > test.log & //在后台ping远程主机。并输出文件到test.log;这种做法也使用于一个以上的档案监视。用Ctrl+c来终止。
实例3:从第5行开始显示文件
命令:
tail -n +5 log2014.log
输出:
[root@localhost test]# cat log2014.log
2014-01
2014-02
2014-03
2014-04
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
==============================
[root@localhost test]# tail -n +5 log2014.log
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
==============================
- linux文件目录操作命令 tail
- 【Linux文件目录命令】tail命令
- linux命令学习-文件目录之tail命令
- Linux 命令(文件和目录管理 - tail)
- linux 下日志文件操作的基本命令(tail,grep)
- linux 下日志文件操作的基本命令(tail,grep)
- 文件/目录操作(3)——cat、tac、more、head、tail、od命令
- Linux命令简介(目录操作命令、文件操作命令)
- linux查看文件命令 head sed tail
- Linux文件查看命令:tail,less,wc
- Linux查看日志文件命令tail
- Linux下tail命令查看文件内容
- linux常用命令之文件目录操作命令
- linux基本命令-文件与目录操作
- Linux-常用文件和目录操作命令
- Linux文件和目录操作命令大全
- linux 文件目录操作命令 ls
- linux文件目录操作命令 cd
- linux学习
- 在浏览器里判断设备来源,跳转到不同的App下载页JS
- listview和recyclerview多布局
- AndroidStudio中使用的dependencies的含义:
- Android中的Adapter 详解(一)
- linux文件目录操作命令 tail
- iOS利用代码添加事件到系统日历中
- 第23篇 Linux下布署AppRTC
- (五)员工管理实现模块初步
- iOS 去掉首尾空格和换行符
- DelayQueue
- copy和mutablecopy
- compareTo
- JavaScript计算两个日期之间相差的天数