For faster navigation, this Iframe is preloading the Wikiwand page for wc (Unix).

wc (Unix)

Unix系统wc命令执行结果

wc (英语:word count)是在类UNIX操作系统中的一个命令。

程序从标准输入流或文件列表中读取文件后,生成一个或多个下列的统计信息: 文件包含的字节数、单词数以及文件的行数(也就是换行符的个数)。如果用户提供的是一个文件列表,则会给予每个文件的单独统计和总体统计结果。

wc程序示例:

 $ wc foo bar
      40     149     947 foo
    2294   16638   97724 bar
    2334   16787   98671 total

第一列表示文件中的行数,以上实例表示文本文件foo有40行,而bar文件包含2294行,总计2334行。 第二列表示文件中的单词个数:foo文件包含149个单词,而bar文件中有16638个单词,总计16787个单词。 第三列表示文件中包含的字符个数:foo文件总共有947个字符,而bar文件中有97724个字符,总共有98761个字符。

较新版本的wc可以区别比特字符的统计。区别在于:Unicode字符集包含了多字节的字符。可以通过选择 -c 或是 -m 参数来选择所需的行为。

GNU wc 曾是 GNU textutils软件包的一部分。现在属于GNU coreutils软件包。

用法

[编辑]
  • wc -l <文件名> 输出行数统计
  • wc -c <文件名> 输出字节数统计
  • wc -m <文件名> 输出字符数统计
  • wc -L <文件名> 输出文件中最长一行的长度
  • wc -w <文件名> 输出单词数统计

参见

[编辑]

外部链接

[编辑]
{{bottomLinkPreText}} {{bottomLinkText}}
wc (Unix)
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?