5.12 查看文件的最后10行内容

tail

head命令可以查看一个文件前10行的内容,而按照典型的异想天开式的Unix风格,还可以使用tail命令来查看一个文件最后10行的内容。从headtail,搞懂了吗?

  1. $ tail Paradise_Lost.txt
  2. To the subjected plain - then disappeared
  3. They, looking back, all the eastern side beheld
  4. Of Paradise, so late their happy seat,
  5. Waved over by that flaming brand; the gate
  6. With dreadful faces thronged and fiery arms.
  7. Some natural tears they dropped, but wiped them soon;
  8. The world was all before them, where to choose
  9. Their place of rest, and Providence their guide.
  10. They, hand in hand, with wandering steps and slow,
  11. Through Eden took their solitary way.

为什么要使用tail命令呢?通常,查看日志(log)文件的最后几行内容,才能发现应用程序或者系统的最新运行状况。当然,在这种情况下你还可以使用另一个非常重要的选项,这将在5.15节中介绍。