linux  tail命令,显示文件末尾内容

语法:tail [参数] [参数值] [文件名称]

参数说明:

-n:从文件末尾开始向前显示指定的行数

-f:从文件末尾开始向前显示指定的行数,当文档有新的内容写入时,动态显示新的内容到屏幕上

举例说明:

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

查看1.txt内容

[root@test tools]# cat 1.txt 1234567891011121314151617181920212223

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

查看1.txt末尾5行

[root@test tools]# tail -n 5 1.txt 1920212223

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

tail命令默认显示文件末尾10行内容

[root@test tools]# tail 1.txt 14151617181920212223

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

动态显示1.txt尾部内容

[root@test tools]# tail -f 1.txt 18192021222324252627

写入内容后显示:

[root@test tools]# tail -f 1.txt 18192021222324252627new1new2new3new4new5

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

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