wc命令用於計算字數。wc命令可以計算檔案的Byte數、字數或是列數,若不指定檔案名稱,或是所給予的檔案名爲“-”,則wc指令會從標準輸入設備讀取數據。wc同時也給出所指定檔案的總統計數。
語法:wc [-clw][--help][--version][檔案...]
參考例子:
統計字數:
[root@linux265 ~]# cat test.txt
hello world
hello world
hello world
hello world hello world
[root@linux265 ~]# wc -w test.txt
10 test.txt
參數:
-w 統計字數,或--words:只顯示字數。一個字被定義爲由空白、跳格或換行字元分隔的字元串
-c 統計字節數,或--bytes或--chars:只顯示Bytes數
-l 統計行數,或--lines:只顯示列數
-m 統計字元數
-L 打印最長行的長度
--help 顯示幫助資訊
--version 顯示版本資訊