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
评论暂时关闭