5.9 查看多个文件的前10行内容

head file1 file2

可以用head命令一次查看多个文件的前10行内容。这听起来与cat命令有点相似,确实如此。不过,head命令能够提供一个标题(header)以分隔各个文件,这样就能够容易地区分各个文件。下面是Chaucer的“Canterbury Tales”和Milton的“Paradise Lost”前10行的内容。

  1. $ head Canterbury_Tales.txt Paradise_Lost.txt
  2. ==> Canterbury_Tales.txt <==
  3. Here bygynneth the Book of the Tales of Caunterbury
  4. General Prologue
  5. Whan that Aprill, with his shoures soote
  6. The droghte of March hath perced to the roote
  7. And bathed every veyne in swich licour,
  8. Of which vertu engendred is the flour;
  9. Whan Zephirus eek with his sweete breeth
  10. Inspired hath in every holt and heath
  11. ==> Paradise_Lost.txt <==
  12. Book I
  13. Of Man's first disobedience, and the fruit
  14. Of that forbidden tree whose mortal taste
  15. Brought death into the World, and all our woe,
  16. With loss of Eden, till one greater Man
  17. Restore us, and regain the blissful seat,
  18. Sing, Heavenly Muse, that, on the secret top
  19. Of Oreb, or of Sinai, didst inspire
  20. That shepherd who first taught the chosen seed

head命令自动用一个空行和标题来分隔两段摘录,这样就能够清楚区分不同的文件。