wc打印换行符,字和字节计数,并且支持多个文件打印,命令格式:
wc [OPTION]... [FILE]...
或
wc [OPTION]... --files0-from=F
常用方式:
-
查看 error.log 日志总行数
1wc
-l error.log
-
查看 error.log 日志总字节数
1wc
-c error.log
-
查看 log 目录下 error.* 类的文件行数
1wc
-l log
/error
.*
参数列表:
-c, --bytes
说明:打印文件的字节总数
-m, --chars
说明:打印文件的字符总数
-l, --lines
说明:打印文件的总行数
--files0-from=F read input from the files specified by
NUL-terminated names in file F;
If F is - then read names from standard input
说明:打印批量指定一些文件,字节,行数,字符数等信息。
当F为文件名时会读取指定的文件名(所读取的文件内容应该是所以指定的文件名列表,并且每个文件名结尾追加 ^@ 特殊符号,注意:这个符号并非^与@而是按 Ctrl+V然后再输入10并且再按其它键即可看到类型 ^@ 蓝色的符号)。如:
文件 test.wc 内容:
sh.log^@test.sh^@
命令:
1
|
wc
--files0-from=
test
.
wc
|
结果:
1
2
3
4
5
6
|
[root@localhost ~]
# wc --files0-from=test.txt
460275 1332379 40275303 sh.log
9 25 338
test
.sh
wc
:
: No such
file
or directory
460284 1332404 40275641 total
|
当F为 - 则表示接收标准输入读取,一般使用 | 管道输入到wc,如:
1
|
find
. -name
'*.log'
-print0 |
wc
--files0-from=-
|
还可以使用命令相看相关说明:
1
|
info
wc
|
-L, --max-line-length
说明:打印文件中长度最长行的行数
-w, --words
说明:打印文件中的单词个数
--help
说明:显示帮助信息
--version
说明:打印当前命令版本信息