主頁(yè) > 知識(shí)庫(kù) > 一個(gè)簡(jiǎn)單的linux命令 tail

一個(gè)簡(jiǎn)單的linux命令 tail

熱門(mén)標(biāo)簽:呼叫中心市場(chǎng)需求 網(wǎng)站排名優(yōu)化 百度競(jìng)價(jià)排名 鐵路電話系統(tǒng) 服務(wù)外包 Linux服務(wù)器 地方門(mén)戶網(wǎng)站 AI電銷(xiāo)

tail命令從指定點(diǎn)開(kāi)始將文件寫(xiě)到標(biāo)準(zhǔn)輸出.使用tail命令的-f選項(xiàng)可以方便的查閱正在改變的日志文件,tail -f filename會(huì)把filename里最尾部的內(nèi)容顯示在屏幕上,并且不但刷新,使你看到最新的文件內(nèi)容.

命令格式

tail[必要參數(shù)][選擇參數(shù)][文件]

命令參數(shù)

-f 循環(huán)讀取
-q 不顯示處理信息
-v 顯示詳細(xì)的處理信息
-c數(shù)目> 顯示的字節(jié)數(shù)
-n行數(shù)> 顯示行數(shù)
–pid=PID 與-f合用,表示在進(jìn)程ID,PID死掉之后結(jié)束.
-q, –quiet, –silent 從不輸出給出文件名的首部
-s, –sleep-interval=S 與-f合用,表示在每次反復(fù)的間隔休眠S秒

使用實(shí)例

實(shí)例1:顯示文件末尾內(nèi)容

命令:
tail -n 5 log2014.log

輸出:

[root@localhost test]# tail -n 5 log2014.log 
2014-09
2014-10
2014-11
2014-12
==============================[root@localhost test]#

說(shuō)明:
顯示文件最后5行內(nèi)容

實(shí)例2:循環(huán)查看文件內(nèi)容

命令:
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 ~]#

說(shuō)明:
ping 192.168.120.204 > test.log //在后臺(tái)ping遠(yuǎn)程主機(jī)。并輸出文件到test.log;這種做法也使用于一個(gè)以上的檔案監(jiān)視。用Ctrl+c來(lái)終止。

實(shí)例3:從第5行開(kāi)始顯示文件

命令:
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
==============================

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • 解決python nohup linux 后臺(tái)運(yùn)行輸出的問(wèn)題
  • php守護(hù)進(jìn)程 加linux命令nohup實(shí)現(xiàn)任務(wù)每秒執(zhí)行一次
  • linux tail 查看日志文件方法
  • 詳解linux tail命令顯示最后n行
  • Linux中tail命令用法詳解
  • 一天一個(gè)shell命令 linux文本操作系列-head,tail命令詳解
  • PHP實(shí)現(xiàn)linux命令tail -f
  • linux nohup及tail-f用法

標(biāo)簽:仙桃 銅川 湖南 蘭州 湘潭 衡水 黃山 崇左

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《一個(gè)簡(jiǎn)單的linux命令 tail》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢(xún)

    • 400-1100-266