4

Linux常用命令-16:tail

 1 year ago
source link: https://xugaoxiang.com/2022/06/04/linux-cmds-16-tail/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

tail 命令用于显示文件尾部的内容,和 head 命令对应。不接参数时默认在屏幕上显示指定文件的最后10行。

语法格式:tail [参数]

常用参数:

dfad0e3b0596df23.png
# 默认显示
tail test.txt

# 显示文件的最后20行
tail -n 20 test.txt

# 显示文件的最后20个字符
tail -c 20 test.txt

# 显示从第20行到结尾的内容
tail +20 test.txt

# 同时显示多个文件,内容之间会显示所属文件名
tail test1.txt test2.txt test3.txt

# 如果是一个不断更新的文件,像日志,可以指定每次显示文件的最后几行,方便查看
tail -f 20 test.txt

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK