精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > linux中head命令的詳細(xì)解釋

      linux中head命令的詳細(xì)解釋

      時(shí)間: 佳洲1085 分享

      linux中head命令的詳細(xì)解釋

        linxu下的head命令是經(jīng)常使用到的顯示文件內(nèi)容的命令。下面由學(xué)習(xí)啦小編為大家整理了linux的head命令的詳細(xì)解釋的相關(guān)知識(shí),希望對(duì)大家有幫助!

        一、linux中的head命令的詳細(xì)解釋

        head 與 tail 就像它的名字一樣的淺顯易懂,它是用來(lái)顯示開頭或結(jié)尾某個(gè)數(shù)量的文字區(qū)塊,head 用來(lái)顯示檔案的開頭至標(biāo)準(zhǔn)輸出中,而 tail 想當(dāng)然爾就是看檔案的結(jié)尾。

        1.命令格式:

        head [參數(shù)]… [文件]…

        2.命令功能:

        head 用來(lái)顯示檔案的開頭至標(biāo)準(zhǔn)輸出中,默認(rèn)head命令打印其相應(yīng)文件的開頭10行。

        3.命令參數(shù):

        -q 隱藏文件名

        -v 顯示文件名

        -c<字節(jié)> 顯示字節(jié)數(shù)

        -n<行數(shù)> 顯示的行數(shù)

        二、linux中的head命令的詳解實(shí)例

        實(shí)例1:顯示文件的前n行

        命令:

      1
      head -n 5 log2014.log

        輸出:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      [root@localhost test]# cat log2014.log
      2014-01
      2014-02
      2014-03
      2014-04
      2014-05
      2014-06
      2014-07
      2014-08
      2014-09
      2014-10
      2014-11
      2014-12
      ==============================
      [root@localhost test]# head -n 5 log2014.log
      2014-01
      2014-02
      2014-03
      2014-04
      2014-05[root@localhost test]#

        實(shí)例2:顯示文件前n個(gè)字節(jié)

        命令:

      1
      head -c 20 log2014.log

        輸出:

      1
      2
      3
      4
      5
      [root@localhost test]# head -c 20 log2014.log
      2014-01
      2014-02
      2014
      [root@localhost test]#

        實(shí)例3:文件的除了最后n個(gè)字節(jié)以外的內(nèi)容

        命令:

      1
      head -c -32 log2014.log

        輸出:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      [root@localhost test]# head -c -32 log2014.log
      2014-01
      2014-02
      2014-03
      2014-04
      2014-05
      2014-06
      2014-07
      2014-08
      2014-09
      2014-10
      2014-11
      2014-12[root@localhost test]#

        實(shí)例4:輸出文件除了最后n行的全部?jī)?nèi)容

        命令:

      1
      head -n -6 log2014.log

        輸出:

      1
      2
      3
      4
      5
      6
      7
      8
      [root@localhost test]# head -n -6 log2014.log
      2014-01
      2014-02
      2014-03
      2014-04
      2014-05
      2014-06
      2014-07[root@localhost test]#

        三、參考資料:linux中的tail命令詳解

        tail (tail) 用來(lái)顯示檔案的結(jié)尾(默認(rèn)為10行)至標(biāo)準(zhǔn)輸出中。若指定了多于一個(gè)文件,程序會(huì)在每段輸出的開始添加相應(yīng)文件名作為頭。如果不指定文件或文件為"-" ,則從標(biāo)準(zhǔn)輸入讀取數(shù)據(jù)。

        2、用法

        nl [選項(xiàng)]... [文件]...

        3、選項(xiàng)

        -c, --bytes=K 輸出最后K字節(jié);另外,使用-c +K 從每個(gè)文件的第K 字節(jié)輸出

        -f, --follow[={name|descriptor}] 即時(shí)輸出文件變化后追加的數(shù)據(jù)。

        -n, 輸出最后K行;另外,使用-n +K 從每個(gè)文件的第K行輸出

        --pid=PID 同 -f 一起使用,當(dāng) PID 所對(duì)應(yīng)的進(jìn)程死去后終止

        -s, --sleep-interval=N 與-f合用,表示在每次反復(fù)的間隔休眠N秒

      3635326