小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

每天一個(gè)linux命令(40):wc命令

 昵稱6656145 2015-02-06

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ù)。如果沒(méi)有給出文件名,則從標(biāo)準(zhǔn)輸入讀取。wc同時(shí)也給出所指定文件的總統(tǒng)計(jì)數(shù)。

3.命令參數(shù):

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

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

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

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

-L 打印最長(zhǎng)行的長(zhǎng)度。

-help 顯示幫助信息

--version 顯示版本信息

4.使用實(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 

test.txt

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

70 test.txt

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

test.txt

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

70 test.txt

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

17 test.txt

說(shuō)明:

7     8     70     test.txt

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

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

命令:

輸出:

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

test.txt

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

7[root@localhost test]#

說(shuō)明:

使用管道線,這在編寫(xiě)shell腳本時(shí)特別有用。

實(shí)例3:用來(lái)統(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]#

說(shuō)明:

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

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多