首页
首页 » 文档编辑 » wc(word count)

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

-c, --bytes

Print byte count only.

-l, --lines

Print line count only.

-L, --max-line-length

Print length of longest line.

-m, --chars

Print character count only.

-w, --words

Print word count only.

--help

Print help message and then exit.

--version

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