Linux 读取文件:tail 命令(后 10 行) 0 个改进

'tail' 命令显示文件最后几行内容。主要用于读取错误日志信息。

命令默认读取文件最后10行内容。

语法:

tail <file name>  
# tail <文件名称>

举例:

$ tail jtp.txt  

Linux File tail

以上截图中,使用 "tail jtp.txt" 命令显示 jtp.txt 文件最后10行内容信息。

Linux tail 命令 -n 选项

'tail -n' 命令选项显示文件最后指定行数的内容。

语法:

tail -n<number> <file name>  
# tail -n<行数> <文件名称>

举例:

$ tail -n5 jtp.txt  

Linux File tail n

以上截图中,使用 "tail -n5 jtp.txt" 命令显示 jtp.txt 文件最后5行内容信息。

tail 命令 -c 选项

tail -c 命令选项显示文件以指定字符计数的最后内容。

语法

tail -c<number> <file name>  
#tail -c<字符数> <文件名称>

举例:

$ tail -c12 jtp.txt  

Linux File tail c

如上截图所示,使用 "tail -c12 jtp.txt" 命令显示 jtp.txt 文件最后12个字符内容信息。(译注:回车也算,Linux 系统文档回车是单字符 '\n'

本文为 Wiki 文章,邀您参与纠错、纰漏和优化
讨论数量: 1

可能有用的命令,实时查看log日志变化并输出

$ tail -n10 -f xxxxx.log
2年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!