簡明Linux命令列筆記:head

來源:互聯網
上載者:User
文章目錄
  • 選項
  • 注意
  • 樣本

顯示檔案的頭部

head [options] [file-list]

 

參數

file-list 為要head顯示的檔案的路徑名列表。當指定多個檔案時,head在顯示每個檔案的前幾行內容之前顯示對應的檔案名稱

當不指定檔案時,head將從標準輸入獲得輸入

 

選項

-c n                顯示檔案的前n個位元組(字元)

-n n                顯示檔案的前n行,也可以使用-n來指定顯示的n行

-q                   當在命令列上指定多個檔案名稱時,它禁止顯示頭部

 

注意

預設情況下,head將顯示檔案的前10行

 

樣本

原檔案

$ cat demoline oneline twoline threeline fourline fiveline sixline sevenline eightline nineline tenline eleven

 

head
$ head demoline oneline twoline threeline fourline fiveline sixline sevenline eightline nineline ten

預設顯示10行

 

head -n
$ head -n 4 demoline oneline twoline threeline four

顯示指定的行數

 

head -n 負數
$ head -n -4 demoline oneline twoline threeline fourline fiveline sixline seven

顯出除最後4行外的其他行

 

head -3 多個檔案
$ head -3 demo dd==> demo <==line oneline twoline three==> dd <==line oneline twoline three

顯示多個檔案的前3行

 

head -c
$ head -c 4 demoline$ 

顯示檔案的前4個字元,注意此處不換行

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.