5.9 查看多个文件的前10行内容
head file1 file2
可以用head
命令一次查看多个文件的前10行内容。这听起来与cat
命令有点相似,确实如此。不过,head
命令能够提供一个标题(header)以分隔各个文件,这样就能够容易地区分各个文件。下面是Chaucer的“Canterbury Tales”和Milton的“Paradise Lost”前10行的内容。
$ head Canterbury_Tales.txt Paradise_Lost.txt
==> Canterbury_Tales.txt <==
Here bygynneth the Book of the Tales of Caunterbury
General Prologue
Whan that Aprill, with his shoures soote
The droghte of March hath perced to the roote
And bathed every veyne in swich licour,
Of which vertu engendred is the flour;
Whan Zephirus eek with his sweete breeth
Inspired hath in every holt and heath
==> Paradise_Lost.txt <==
Book I
Of Man's first disobedience, and the fruit
Of that forbidden tree whose mortal taste
Brought death into the World, and all our woe,
With loss of Eden, till one greater Man
Restore us, and regain the blissful seat,
Sing, Heavenly Muse, that, on the secret top
Of Oreb, or of Sinai, didst inspire
That shepherd who first taught the chosen seed
head
命令自动用一个空行和标题来分隔两段摘录,这样就能够清楚区分不同的文件。