濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > linux命令大全之wc命令詳解(統(tǒng)計(jì)文件字節(jié)數(shù))

linux命令大全之wc命令詳解(統(tǒng)計(jì)文件字節(jié)數(shù))

熱門標(biāo)簽:外呼系統(tǒng)鏈接 商店地圖標(biāo)注外賣入駐 桂林市ai電銷機(jī)器人公司 地圖標(biāo)注的牌子 制作地圖標(biāo)注 新科火車站地圖標(biāo)注點(diǎn) 地址高德地圖標(biāo)注 外呼系統(tǒng)怎么弄 磁力導(dǎo)航地圖標(biāo)注

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同時(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
輸出:

復(fù)制代碼
代碼如下:

[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ù)字不打印文件名
命令:wc -l test.txt
輸出:

復(fù)制代碼
代碼如下:

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

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

實(shí)例3:用來統(tǒng)計(jì)當(dāng)前目錄下的文件數(shù)
命令:ls -l | wc -l
輸出:

復(fù)制代碼
代碼如下:

[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)前目錄

標(biāo)簽:濱州 亳州 綏化 保山 常德 江蘇 河源 宿州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《linux命令大全之wc命令詳解(統(tǒng)計(jì)文件字節(jié)數(shù))》,本文關(guān)鍵詞  linux,命令,大全,之,詳解,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《linux命令大全之wc命令詳解(統(tǒng)計(jì)文件字節(jié)數(shù))》相關(guān)的同類信息!
  • 本頁收集關(guān)于linux命令大全之wc命令詳解(統(tǒng)計(jì)文件字節(jié)數(shù))的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    内乡县| 萝北县| 商河县| 雅安市| 江陵县| 宜城市| 胶州市| 历史| 泰安市| 乌兰县| 蒲江县| 曲周县| 辰溪县| 康保县| 郧西县| 香格里拉县| 微山县| 贵州省| 天镇县| 通河县| 湘阴县| 广东省| 蒲江县| 英德市| 海丰县| 郯城县| 开化县| 瑞安市| 定州市| 裕民县| 宝兴县| 无锡市| 都兰县| 石台县| 东辽县| 灵武市| 绍兴市| 舒城县| 安顺市| 临夏市| 巴林右旗|