麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統(tǒng) > Linux > 正文

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

2020-03-01 06:57:48
字體:
供稿:網(wǎng)友

  在html' target='_blank'>Linux系統(tǒng)中,wc命令不太經(jīng)常用到,只是在統(tǒng)計字數(shù)的時候才會使用該命令,那么下面由 小編為大家整理了linux系統(tǒng)中wc命令的詳細解釋的相關(guān)知識,希望對大家有幫助!

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

  1.命令格式:

  wc [選項]文件…

  2.命令功能:

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

  3.命令參數(shù):

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

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

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

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

  -L 打印最長行的長度。

  --help 顯示幫助信息

  --version 顯示版本信息

  Linux系統(tǒng)中wc命令的具體實例

  實例1:查看文件的字節(jié)數(shù)、字數(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ù) 文件名

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

  命令:

  輸出:

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

  7 test.txt

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

  7[root@localhost test]#

  說明:

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

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

  命令:

  ls -l | wc -l

  輸出:

  [root@localhost test]# cd test6

  [root@localhost test6]# ll

  總計 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ù)量中包含當前目錄

  知識擴展:Linux系統(tǒng)中wc命令的-help說明

  建議用--help查看使用說明:

  Usage: wc [OPTION]... [FILE]...

  or: wc [OPTION]... --files0-from=F

  Print newline, word, and byte counts for each FILE, and a total line if

  more than one FILE is specified. With no FILE, or when FILE is -,

  read standard input. A word is a non-zero-length sequence of characters

  delimited by white space.

  The options below may be used to select which counts are printed, always in

  the following order: newline, word, character, byte, maximum line length.

  -c, --bytes print the byte counts

  -m, --chars print the character counts

  -l, --lines print the newline counts

  --files0-from=F read input from the files specified by

  NUL-terminated names in file F;

  If F is - then read names from standard input

  -L, --max-line-length print the length of the longest line

  -w, --words print the word counts

  --help display this help and exit

  --version output version information and exit

  單詞:

  Usage:用法

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 一区二区免费看 | 亚洲午夜不卡 | 99热久草| 国产色爱综合网 | 欧美城网站地址 | 免费一级特黄毛片 | 成人毛片免费看 | 久久精品国产久精国产 | 黄污网站在线 | 竹内纱里奈和大战黑人 | 国产高清成人久久 | 欧美日韩大片在线观看 | 日本一区二区视频在线观看 | 成人 精品| 黄色伊人网站 | 凹凸成人精品亚洲精品密奴 | 国产1级视频| av在线更新 | 国产精品99久久久久久久女警 | 九一免费国产 | 黄色片网站在线看 | 成人三级电影网站 | 国产精品久久久久久久久久久久午夜 | 成人一区视频 | 久久91精品国产91久久yfo | av电影免费播放 | 国产一级做a爱片在线看免 2019天天干夜夜操 | 在线成人免费av | 日本在线视频一区二区三区 | 亚洲天堂成人在线 | 护士hd老师fre0性xxx | 成人免费av在线播放 | 国产成人精品二区 | chinese-xvideos | 男男啪羞羞视频网站 | av久草| 片在线观看 | 日韩在线激情 | 一级片九九 | 天天透天天狠天天爱综合97 | 久久亚洲国产精品 |