最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

  發(fā)布時間:2014-04-09 15:07:27   作者:佚名   我要評論
Linux系統(tǒng)中的wc(Word Count)命令的功能為統(tǒng)計指定文件中的字節(jié)數、字數、行數,并將統(tǒng)計結果顯示輸出

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 顯示版本信息

4.使用實例:
實例1:查看文件的字節(jié)數、字數、行數
命令: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
行數   單詞數  字節(jié)數   文件名


實例2:用wc命令怎么做到只打印統(tǒng)計數字不打印文件名
命令:wc -l test.txt
輸出:

復制代碼
代碼如下:

[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)計當前目錄下的文件數
命令: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]#

說明:
數量中包含當前目錄

相關文章

  • linux wc命令應用舉例

    我們通常會使用linux下的wc命令和其它命令結合來計算行和其他信息
    2013-02-13
  • linux wc命令參數及用法詳解

    wc命令的功能為統(tǒng)計指定文件中的字節(jié)數、字數、行數, 并將統(tǒng)計結果顯示輸出
    2012-09-21

最新評論

清水县| 壤塘县| 青铜峡市| 鹿邑县| 丰都县| 永川市| 沁阳市| 南木林县| 梅州市| 沙河市| 山阴县| 澄城县| 榆社县| 尚义县| 忻州市| 双鸭山市| 高要市| 金湖县| 聂荣县| 汉川市| 扬州市| 巧家县| 永平县| 儋州市| 平阴县| 江源县| 金沙县| 昌都县| 甘肃省| 眉山市| 丹棱县| 加查县| 西盟| 垫江县| 洪湖市| 九龙坡区| 宣武区| 兴城市| 安国市| 涿州市| 霍林郭勒市|