单词统计函数 - WC

wc (short for word count) is a command in Unix-like operating systems.

The program reads either standard input or a list of files and generates one or more of the following statistics: number of bytes, number of words, and number of lines (specifically, the number of newline characters). If a list of files is provided, both individual file and total statistics follow.

Sample execution of wc:

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

The first column is the count of newlines, meaning that the text file foo has 40 newlines while bar has 2294 newlines- resulting in a total of 2334 newlines. The second column indicates the number of words in each text file showing that there are 149 words in foo and 16638 words in bar- giving a total of 16787 words. The last column indicates the number of characters in each text file, meaning that the file foo has 947 characters while bar has 97724 characters- 98671 characters all in all.

Newer versions of wc can differentiate between byte and character count. This difference arises with Unicode which includes multi-byte characters. The desired behaviour is selected with the -c or -m switch.

GNU wc used to be part of the GNU textutils package; it is now part of GNU coreutils.

Usage

  • wc -l <filename> print the line count
  • wc -c <filename> print the byte count
  • wc -m <filename> print the character count
  • wc -L <filename> print the length of longest line
  • wc -w <filename> print the word count
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值