5.8 查看文件的前10行内容
head
如果你只需要查看一个文件的前10行内容,例如Chaucer的“Canterbury Tales”,就没有必要使用cat
命令或less
命令,使用head
命令就可以了。head
命令可以只打印出文件的前10行内容,然后返回到命令行。
$ head 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 heeth
$
要快速浏览文本文件,head
命令非常棒,即使文件很大也没有关系。只需要一眨眼的时间,你就能知道这个文件是否是你需要的文件。