sese在线视频|婷婷五月天 国产|丝袜在线一区第一页|精品国产污污网址|午夜无套内射视频|91视频亚洲第一|一区二区三区污污|毛片毛片毛片按摩按摩,摸毛片裸体|亚洲熟女av电影|在线观看欧美亚州

學習啦 > 學習電腦 > 操作系統(tǒng) > Linux教程 > Linux系統(tǒng)中wc命令使用詳解

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

時間: 佳洲1085 分享

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

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

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

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

  1.命令格式:

  wc [選項]文件...

  2.命令功能:

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

  3.命令參數:

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

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

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

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

  -L 打印最長行的長度。

  -help 顯示幫助信息

  --version 顯示版本信息

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

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

  wc testfile

  先查看testfile文件的內容,可以看到:

  $ 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)計,結果如下:

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

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

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

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

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

  輸出結果如下:

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

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

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

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

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

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

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

  #wc /etc/passwd

  40 45 1719 /etc/passwd

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

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

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

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

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

  45 /etc/passwd

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

  1719

3645586