一、用法
wc
命令用于統計文件中的字節數、字符數或列數。
-
-c
:統計文件的字符數。 -
-w
:統計文件中的詞語的數量,即被空格以及換行等分隔的字符串。 -
-l
:統計文件的列數。
二、示例
> ll
total 8.0K
-rwxr-xr-x. 1 root root 20 Dec 23 08:02 index.html
-rwxr-xr-x. 1 root root 32 Dec 23 08:02 README.md
> cat index.html # 查看文件內容
<h1>HelloWorld</h1>
> cat README.md # 查看文件內容
# this is a test svn repository
> wc -l * # 統計文件的列數
1 index.html
1 README.md
2 total # 總計
> wc -c * # 統計文件的字節數
20 index.html
32 README.md
52 total
> wc -w * # 統計文件的單詞的數量
1 index.html
7 README.md
8 total