wc(word count)
wc(word count)功能说明:计算字数。
语 法:wc [-clw][--help][--version][文件...]
补充说明:利用wc指令我们可以计算文件的Byte数、字数、或是列数,若不指定文件名称、或是所给予的文件名为“-”,则wc指令会从标准输入设备读取数据。
参 数:
-c或--bytes或--chars 只显示Bytes数。
-l或--lines 只显示列数。
-w或--words 只显示字数。
--help 在线帮助。
--version 显示版本信息。
wc
wc [options] [files]
Print byte, word, and line counts for each file. Print a total line for multiple files. If no files are given, read standard input. See other examples under ls and sort.
Options
Print byte count only.
Print line count only.
Print length of longest line.
Print character count only.
Print word count only.
Print help message and then exit.
Print the version number and then exit.
Examples
Count the number of users logged in:
who | wc -l
Count the words in three essay files:
wc -w essay.[123]
Count lines in the file named by variable $file (don't display filename):
wc -l < $file