Tail For Windows文件命令編程工具是一個免費使用命令行實用程序能夠顯示一個文件的最后一行以及監(jiān)控文件的修改(如日志)。它也可以捕捉任何指定數(shù)量的文件,為了把它變成另一個文件。命令從指定點開始將文件寫到標準輸出.使用tail命令的-f選項可以方便的查閱正在改變的日志文件,tail -f filename會把filename里最尾部的內(nèi)容顯示在屏幕上,并且不但刷新,使你看到最新的文件內(nèi)容.
功能說明
它支持大多數(shù)UNIX / Linux系統(tǒng)兼容的命令。下載的軟件包包括CLI的可執(zhí)行文件,以及一個經(jīng)驗不足的用戶幫助手冊。
使用的語法是:尾[ F ] [ C | B | K L M | | | N + / - ] [數(shù)]的[文件]和[數(shù)]尾+ C | B | K L M N | | | [F] [文件]和尾[民] C | B | K L M N | | | [F] [文件]
調(diào)用應(yīng)用程序的過程中沒有任何命令將顯示指定的文件最近的10線。除了“F”,用來監(jiān)視文件的變化,所有的選項是互斥的。
and +/-[num]b" displays the file in question starting with the location defined by "num". " style="font-family: museo_sans_cond, Arial; font-size: 16px; letter-spacing: -0.100000001490116px; line-height: 21px; white-space: normal; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">例如,“B [±]數(shù)字>和+ / - [民] B“顯示文件中的問題開始的位置定義的“民”。加“-”符號“民”指示工具揭示過去的數(shù)塊文件。否則,如果“-”替換為“+”,程序顯示文件從指定的塊(一塊是512字節(jié))。
此外,“C [±]民”和“+ / - [民] C”與“B”的選擇,而唯一不同的是,“民”是不是時鐘字節(jié)表示。
剩下的選項以及實例和可能的退出狀態(tài)值在產(chǎn)品手冊中提供。
軟件說明
1.命令格式;
tail[必要參數(shù)][選擇參數(shù)][文件]
2.命令功能:
用于顯示指定文件末尾內(nèi)容,不指定文件時,作為輸入信息進行處理。常用查看日志文件。
3.命令參數(shù):
-f 循環(huán)讀取
-q 不顯示處理信息
-v 顯示詳細的處理信息
-c<數(shù)目> 顯示的字節(jié)數(shù)
-n<行數(shù)> 顯示行數(shù)
--pid=PID 與-f合用,表示在進程ID,PID死掉之后結(jié)束.
-q, --quiet, --silent 從不輸出給出文件名的首部
-s, --sleep-interval=S 與-f合用,表示在每次反復(fù)的間隔休眠S秒
4.使用實例:
實例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]#
說明:
顯示文件最后5行內(nèi)容
實例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 ~]#
說明:
ping 192.168.120.204 > test.log & //在后臺ping遠程主機。并輸出文件到test.log;這種做法也使用于一個以上的檔案監(jiān)視。用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
==============================