Linux 读取文件:tail 命令(后 10 行)
'tail' 命令显示文件最后几行内容。主要用于读取错误日志信息。
命令默认读取文件最后10行内容。
语法:
tail <file name>
# tail <文件名称>
举例:
$ tail jtp.txt
以上截图中,使用 "tail jtp.txt" 命令显示 jtp.txt 文件最后10行内容信息。
Linux tail 命令 -n 选项
'tail -n' 命令选项显示文件最后指定行数的内容。
语法:
tail -n<number> <file name>
# tail -n<行数> <文件名称>
举例:
$ tail -n5 jtp.txt
以上截图中,使用 "tail -n5 jtp.txt" 命令显示 jtp.txt 文件最后5行内容信息。
tail 命令 -c 选项
tail -c
命令选项显示文件以指定字符计数的最后内容。
语法
tail -c<number> <file name>
#tail -c<字符数> <文件名称>
举例:
$ tail -c12 jtp.txt
如上截图所示,使用 "tail -c12 jtp.txt" 命令显示 jtp.txt 文件最后12个字符内容信息。(译注:回车也算,Linux 系统文档回车是单字符 '\n')
推荐文章: