国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > Linux系統(tǒng)中wc命令使用詳解

    Linux系統(tǒng)中wc命令使用詳解

    時間: 佳洲1085 分享

    Linux系統(tǒng)中wc命令使用詳解

      Linux系統(tǒng)中wc命令是統(tǒng)計文件文本的字節(jié)數(shù)等并顯示輸出。下面由學(xué)習(xí)啦小編為大家整理了linux系統(tǒng)中wc命令使用詳解,希望對大家有幫助!

      Linux系統(tǒng)中wc命令使用詳解

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

      1.命令格式:

      wc [選項]文件...

      2.命令功能:

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

      3.命令參數(shù):

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

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

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

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

      -L 打印最長行的長度。

      -help 顯示幫助信息

      --version 顯示版本信息

      Linux系統(tǒng)中wc命令詳解實例

      在默認(rèn)的情況下,wc將計算指定文件的行數(shù)、字?jǐn)?shù),以及字節(jié)數(shù)。使用的命令為:

      wc testfile

      先查看testfile文件的內(nèi)容,可以看到:

      $ cat testfile

      Linux networks are becoming more and more common, but scurity is often an overlooked

      issue. Unfortunately, in today’s environment all networks are potential hacker targets,

      fro0m tp-secret military research networks to small home LANs.

      Linux Network Securty focuses on securing Linux in a networked environment, where the

      security of the entire network needs to be considered rather than just isolated machines.

      It uses a mix of theory and practicl techniques to teach administrators how to install and

      use security applications, as well as how the applcations work and why they are necesary.

      使用 wc統(tǒng)計,結(jié)果如下:

      $ wc testfile # testfile文件的統(tǒng)計信息

      3 92 598 testfile # testfile文件的行數(shù)為3、單詞數(shù)92、字節(jié)數(shù)598

      其中,3 個數(shù)字分別表示testfile文件的行數(shù)、單詞數(shù),以及該文件的字節(jié)數(shù)。

      如果想同時統(tǒng)計多個文件的信息,例如同時統(tǒng)計testfile、testfile_1、testfile_2,可使用如下命令:

      wc testfile testfile_1 testfile_2 #統(tǒng)計三個文件的信息

      輸出結(jié)果如下:

      $ wc testfile testfile_1 testfile_2 #統(tǒng)計三個文件的信息

      3 92 598 testfile #第一個文件行數(shù)為3、單詞數(shù)92、字節(jié)數(shù)598

      9 18 78 testfile_1 #第二個文件的行數(shù)為9、單詞數(shù)18、字節(jié)數(shù)78

      3 6 32 testfile_2 #第三個文件的行數(shù)為3、單詞數(shù)6、字節(jié)數(shù)32

      15 116 708 總用量 #三個文件總共的行數(shù)為15、單詞數(shù)116、字節(jié)數(shù)708

      linux系統(tǒng)中wc命令常見用法

      默認(rèn)使用wc統(tǒng)計/etc/passwd

      #wc /etc/passwd

      40 45 1719 /etc/passwd

      40是行數(shù),45是單詞數(shù),1719是字節(jié)數(shù)

      wc的命令比較簡單使用,每個參數(shù)使用如下:

      #wc -l /etc/passwd #統(tǒng)計行數(shù),在對記錄數(shù)時,很常用

      40 /etc/passwd #表示系統(tǒng)有40個賬戶

      #wc -w /etc/passwd #統(tǒng)計單詞出現(xiàn)次數(shù)

      45 /etc/passwd

      #wc -m /etc/passwd #統(tǒng)計文件的字節(jié)數(shù)

      1719

    3645586