Linux系统中的wc(Word Count)命令的功能为统计指定文件中的字节数、字数、行数,并将统计结果显示输出。code
wc [-clw][--help][--version][文件...]
利用wc指令咱们能够计算文件的Byte数、字数、或是列数,若不指定文件名称、或是所给予的文件名为"-",则wc指令会从标准输入设备读取数据。
参数 | 描述 |
---|---|
-c | 统计字节数。 |
-l | 统计行数。 |
-m | 统计字符数。这个标志不能与 -c 标志一块儿使用。 |
-w | 统计字数。一个字被定义为由空白、跳格或换行字符分隔的字符串。 |
-L | 打印最长行的长度。 |
-help | 显示帮助信息 |
--version | 显示版本信息 |
命令:blog
wc 1.log
输出:进程
[root@localhost test]# cat 1.log a bc def [root@localhost test]# wc 1.log 3 3 9 1.log [root@localhost test]# wc -c 1.log 9 1.log [root@localhost test]# wc -l 1.log 3 1.log [root@localhost test]# wc -m 1.log 9 1.log [root@localhost test]# wc -w 1.log 3 1.log [root@localhost test]# wc -L 1.log 3 1.log
说明:字符串
3 3 9 1.log 表明1.log文件的行数为三、单词数三、字节数9io
命令:table
cat 1.log |wc -l
输出:class
[root@localhost test]# wc -l 1.log 3 1.log [root@localhost test]# cat 1.log |wc -l 3
说明:test
使用管道线,便可作到这一点d3
命令:
ls | wc -l
输出:
[root@localhost test]# ls 1.log 2.log 2.log.back 3.log 4.log [root@localhost test]# ls | wc -l 5
说明:
若是当前目录下有子目录,则数量为文件及子目录数量(不包含子目录下面的文件数量)