一、用法

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
最后修改:2018 年 01 月 04 日
喜欢就给我点赞吧