亚洲欧美精品沙发,日韩在线精品视频,亚洲Av每日更新在线观看,亚洲国产另类一区在线5

<pre id="hdphd"></pre>

  • <div id="hdphd"><small id="hdphd"></small></div>
      學(xué)習(xí)啦>學(xué)習(xí)電腦>操作系統(tǒng)>Linux教程>

      linux計(jì)數(shù)命令

      時間: 佳洲1085 分享

        linux下通過wc命令可以幫我們統(tǒng)計(jì)計(jì)數(shù)。那么它的具體語法是什么呢?下面由學(xué)習(xí)啦小編為大家整理了linux基礎(chǔ)命令的相關(guān)知識,希望大家喜歡!

        一、linux計(jì)數(shù)命令wc命令詳解

        Linux系統(tǒng)中的wc(Word Count)命令的功能為統(tǒng)計(jì)指定文件中的字節(jié)數(shù)、字?jǐn)?shù)、行數(shù),并將統(tǒng)計(jì)結(jié)果顯示輸出。

        1.命令格式:

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

        2.命令功能:

        統(tǒng)計(jì)指定文件中的字節(jié)數(shù)、字?jǐn)?shù)、行數(shù),并將統(tǒng)計(jì)結(jié)果顯示輸出。該命令統(tǒng)計(jì)指定文件中的字節(jié)數(shù)、字?jǐn)?shù)、行數(shù)。如果沒有給出文件名,則從標(biāo)準(zhǔn)輸入讀取。wc同時也給出所指定文件的總統(tǒng)計(jì)數(shù)。

        3.命令參數(shù):

        -c 統(tǒng)計(jì)字節(jié)數(shù)。

        -l 統(tǒng)計(jì)行數(shù)。

        -m 統(tǒng)計(jì)字符數(shù)。這個標(biāo)志不能與 -c 標(biāo)志一起使用。

        -w 統(tǒng)計(jì)字?jǐn)?shù)。一個字被定義為由空白、跳格或換行字符分隔的字符串。

        -L 打印最長行的長度。

        -help 顯示幫助信息

        --version 顯示版本信息

        二、linux計(jì)數(shù)命令wc命令使用實(shí)例

        實(shí)例1:查看文件的字節(jié)數(shù)、字?jǐn)?shù)、行數(shù)

        命令:

        wc test.txt

        輸出:

        [root@localhost test]# cat test.txt

        hnlinux

        peida.cnblogs.com

        ubuntu

        ubuntu linux

        redhat

        Redhat

        linuxmint

        [root@localhost test]# wc test.txt

        7 8 70 test.txt

        [root@localhost test]# wc -l test.txt

        7 test.txt

        [root@localhost test]# wc -c test.txt

        70 test.txt

        [root@localhost test]# wc -w test.txt

        8 test.txt

        [root@localhost test]# wc -m test.txt

        70 test.txt

        [root@localhost test]# wc -L test.txt

        17 test.txt

        說明:

        7 8 70 test.txt

        行數(shù) 單詞數(shù) 字節(jié)數(shù) 文件名

        實(shí)例2:用wc命令怎么做到只打印統(tǒng)計(jì)數(shù)字不打印文件名

        命令:

        輸出:

        [root@localhost test]# wc -l test.txt

        7 test.txt

        [root@localhost test]# cat test.txt |wc -l

        7[root@localhost test]#

        說明:

        使用管道線,這在編寫shell腳本時特別有用。

        實(shí)例3:用來統(tǒng)計(jì)當(dāng)前目錄下的文件數(shù)

        命令:

        ls -l | wc -l

        輸出:

        [root@localhost test]# cd test6

        [root@localhost test6]# ll

        總計(jì) 604

        ---xr--r-- 1 root mail 302108 11-30 08:39 linklog.log

        ---xr--r-- 1 mail users 302108 11-30 08:39 log2012.log

        -rw-r--r-- 1 mail users 61 11-30 08:39 log2013.log

        -rw-r--r-- 1 root mail 0 11-30 08:39 log2014.log

        -rw-r--r-- 1 root mail 0 11-30 08:39 log2015.log

        -rw-r--r-- 1 root mail 0 11-30 08:39 log2016.log

        -rw-r--r-- 1 root mail 0 11-30 08:39 log2017.log

        [root@localhost test6]# ls -l | wc -l

        8

        [root@localhost test6]#

        說明:

        數(shù)量中包含當(dāng)前目錄

      linux計(jì)數(shù)命令

      linux下通過wc命令可以幫我們統(tǒng)計(jì)計(jì)數(shù)。那么它的具體語法是什么呢?下面由學(xué)習(xí)啦小編為大家整理了linux基礎(chǔ)命令的相關(guān)知識,希望大家喜歡! 一、linux計(jì)數(shù)命令wc命令詳解 Linux系統(tǒng)中的wc(Word Count)命令的功能為統(tǒng)計(jì)指定文件中的字節(jié)數(shù)
      推薦度:
      點(diǎn)擊下載文檔文檔為doc格式

      精選文章

      • linux基礎(chǔ)命令
        linux基礎(chǔ)命令

        linux命令如此之多,但其實(shí)我們只需要掌握我們最常用的基礎(chǔ)命令就可以了。下面由學(xué)習(xí)啦小編為大家整理了linux基礎(chǔ)命令的相關(guān)知識,希望大家喜歡! lin

      • linux基本命令free
        linux基本命令free

        在linux系統(tǒng)監(jiān)控的工具中,free命令是最經(jīng)常使用的命令之一。下面由學(xué)習(xí)啦小編為大家整理了linux基本命令free命令的相關(guān)知識,希望大家喜歡! 一、linux基本

      • linux獲取文件內(nèi)容命令
        linux獲取文件內(nèi)容命令

        linux下讀取文件內(nèi)容的命令比較多:cat tac nl more less head tail od等,下面由學(xué)習(xí)啦小編為大家整理了linux獲取文件內(nèi)容的命令,希望大家喜歡! linux獲取文件內(nèi)

      • linux獲解析命令行參數(shù)
        linux獲解析命令行參數(shù)

        在linux下有時候會遇到長選項(xiàng)的命令行參數(shù)要怎么解析它呢?下面由學(xué)習(xí)啦小編為大家整理了linux解析命令行參數(shù)的相關(guān)知識,希望對大家有所幫助。 linux下

      3599416