head 命令可用于查看文件的開頭部分的內容,有一個常用的參數 -n 用于顯示行數,默認為 10,即顯示 10 行的內容。
命令格式:
head [參數] [文件]
參數:
實例
要顯示 runoob_notes.log 文件的開頭 10 行,請輸入以下命令:
head runoob_notes.log
顯示 notes.log 文件的開頭 5 行,請輸入以下命令:
head -n 5 runoob_notes.log
顯示文件前 20 個字節:
head -c 20 runoob_notes.log