5.8 查看文件的前10行内容

head

如果你只需要查看一个文件的前10行内容,例如Chaucer的“Canterbury Tales”,就没有必要使用cat命令或less命令,使用head命令就可以了。head命令可以只打印出文件的前10行内容,然后返回到命令行。

  1. $ head Canterbury_Tales.txt
  2. Here bygynneth the Book of the Tales of Caunterbury
  3. General Prologue
  4. Whan that Aprill, with his shoures soote
  5. The droghte of March hath perced to the roote
  6. And bathed every veyne in swich licour,
  7. Of which vertu engendred is the flour;
  8. Whan Zephirus eek with his sweete breeth
  9. Inspired hath in every holt and heeth
  10. $

要快速浏览文本文件,head命令非常棒,即使文件很大也没有关系。只需要一眨眼的时间,你就能知道这个文件是否是你需要的文件。