linux wc简要说明:
[123@123 123]$ wc --help
用法:wc [选项]... [文件]...
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. With no FILE, or when FILE is -,
read standard input.
-c, --bytes print the byte counts
-m, --chars print the character counts
-l, --lines print the newline counts
-L, --max-line-length print the length of the longest line
-w, --words print the word counts
--help 显示此帮助信息并退出
--version 输出版本信息并退出
1.txt:
ab c
def
2.txt:
123
wc命令主要做统计使用,会显示每个文件的行数、语句数以及字节数:
[123@123 123]$ wc 1.txt
2 3 8 1.txt
[123@123 123]$ wc -lwc 1.txt
2 3 8 1.txt
1.txt中数据有2行,3个短语,8个字节(wc == wc -lwc)
如果统计多个文件,将会增加一行统计数据:
[123@123 123]$ wc 1.txt 2.txt
2 3 9 1.txt
1 1 4 2.txt
3 4 13 总计
如果没有显示的带文件选项,将会直接读取输入信息:
[123@123 123]$ cat 1.txt|wc
2 3 9
[123@123 123]$ ls -l|wc -l
19