歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> linux命令--tail,linux--tail

linux命令--tail,linux--tail

日期:2017/3/3 18:11:12   编辑:學習Linux

linux命令--tail,linux--tail

linux命令--tail,linux--tail


linux tail命令,顯示文件末尾內容

語法:tail [參數] [參數值] [文件名稱]

參數說明:

-n:從文件末尾開始向前顯示指定的行數

-f:從文件末尾開始向前顯示指定的行數,當文檔有新的內容寫入時,動態顯示新的內容到屏幕上

舉例說明:

------------------------------------------------------------------------------------------------------------------------

查看1.txt內容

[root@test tools]# cat 1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

--------------------------------------------------------------------------------------------------------------------

查看1.txt末尾5行

[root@test tools]# tail -n 5 1.txt
19
20
21
22
23

--------------------------------------------------------------------------------------------------------------------

tail命令默認顯示文件末尾10行內容

[root@test tools]# tail 1.txt
14
15
16
17
18
19
20
21
22
23

--------------------------------------------------------------------------------------------------------------------

動態顯示1.txt尾部內容

[root@test tools]# tail -f 1.txt
18
19
20
21
22
23
24
25
26
27

寫入內容後顯示:

[root@test tools]# tail -f 1.txt
18
19
20
21
22
23
24
25
26
27
new1
new2
new3
new4
new5

-----------------------------------------------------------------------------------------------------------------

Ctrl+c 結束正在運行的程序,結束tail -f 命令,可使用Ctrl+c

http://xxxxxx/Linuxjc/1161733.html TechArticle

Copyright © Linux教程網 All Rights Reserved