LINUX

LINUX HEAD指令

介紹

head指令用來檢視檔案的前十行。

語法

head [options] [files]

常用的options

-n N  Print the first N lines instead of 10.

-N    Same as -n N.

-c N  Print the first N bytes of the file.

-q    Quiet mode: when processing more than one file, don't print a banner above each file. Normally, head prints a banner containing the filename.

範例

你可以檢視檔案的前十行,或預覽檔案:

⤍ head myfile

搭配萬用字元,你可以預覽所有myfile開頭的檔案:

⤍ head myfile*

當資料非常多時,可以搭配管線less指令讓閱讀更方便:

⤍ head myfile* | less

搭配ls指令,你可以查看最近10筆修改的檔名:

⤍ ls -at | head

⤍ ls -alt | head

發佈留言