这里我们再看一个命令,wc(word count)统计指定文件中的字节数、字数、行数,并将统计结果显示输出
参考网址:http://www.cnblogs.com/peida/archive/2012/12/18/2822758.html
用法:
用法:wc [选项]... [文件]...
或:wc [选项]... --files0-from=F
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. A word is a non-zero-length sequence of characters
delimited by white space.
The options below may be used to select which counts are printed, always in
the following order: newline, word, character, byte, maximum line length.
-c, --bytes print the byte counts
-m, --chars print the character counts
-l, --lines print the newline counts
--files0-from=文件 从指定文件读取以NUL 终止的名称,如果该文件被
指定为"-"则从标准输入读文件名
-L, --max-line-length 显示最长行的长度
-w, --words 显示单词计数
--help 显示此帮助信息并退出
--version 显示版本信息并退出
请向bug-coreutils@gnu.org 报告wc 的错误
GNU coreutils 的主页:<http://www.gnu.org/software/coreutils/>
GNU 软件一般性帮助:<http://www.gnu.org/gethelp/>
请向<http://translationproject.org/team/zh_CN.html> 报告wc 的翻译错误
要获取完整文档,请运行:info coreutils 'wc invocation'
统计指定文件中的字节数、字数、行数,并将统计结果显示输出。该命令统计指定文件中的字节数、字数、行数。如果没有给出文件名,则从标准输入读取。wc同时也给出所指定文件的总统计数。
-c 统计字节数。
-l 统计行数。
-m 统计字符数。这个标志不能与 -c 标志一起使用。
-w 统计字数。一个字被定义为由空白、跳格或换行字符分隔的字符串。
示例:
我们的file02中,有一下内容:
1. wc命令
这里的解释行数(3),单词数(4),字节数(20),文件名(file02)
2. wc -c 统计字节数
3. wc -l 统计行数