tail 命令用于查看文件的內(nèi)容,常用參數(shù)? -f? 常用于查閱正在改變的日志文件
tail -f filename 會把filename文件里的最尾部的內(nèi)容顯示在屏幕上腊徙,并且不斷刷新移怯,只要filename更新就可以看到最新的文件內(nèi)容
命令格式:
tail? [參數(shù)]? [文件]
-f? ?循環(huán)讀取
-q? 不顯示處理信息
-v? 顯示詳細(xì)的處理信息
-c<數(shù)目>? 顯示的字節(jié)數(shù)
-n<行數(shù)>? 顯示行數(shù)
例:
要顯示 notes.log 文件的最后 10 行琉闪,請輸入以下命令:
tail? notes.log
要跟蹤名為 notes.log 的文件的增長情況邦泄,請輸入以下命令:
tail -f notes.log
此命令顯示 notes.log 文件的最后 10 行删窒。當(dāng)將某些行添加至 notes.log 文件時,tail 命令會繼續(xù)顯示這些行顺囊。 顯示一直繼續(xù)肌索,直到您按下(Ctrl-C)組合鍵停止顯示。
顯示文件 notes.log 的內(nèi)容特碳,從第 20 行至文件末尾:
tail +20 notes.log
顯示文件 notes.log 的最后 10 個字符:
tail -c 10 notes.log