5.12 查看文件的最后10行内容
tail
head
命令可以查看一个文件前10行的内容,而按照典型的异想天开式的Unix风格,还可以使用tail
命令来查看一个文件最后10行的内容。从head
到tail
,搞懂了吗?
$ tail Paradise_Lost.txt
To the subjected plain - then disappeared
They, looking back, all the eastern side beheld
Of Paradise, so late their happy seat,
Waved over by that flaming brand; the gate
With dreadful faces thronged and fiery arms.
Some natural tears they dropped, but wiped them soon;
The world was all before them, where to choose
Their place of rest, and Providence their guide.
They, hand in hand, with wandering steps and slow,
Through Eden took their solitary way.
为什么要使用tail
命令呢?通常,查看日志(log)文件的最后几行内容,才能发现应用程序或者系统的最新运行状况。当然,在这种情况下你还可以使用另一个非常重要的选项,这将在5.15节中介绍。