简体   繁体   English

计算cshell中一行中的单词数

[英]count number of words in a line in cshell

I need to count the number of words in a line, in cshell. 我需要在cshell中计算一行中的单词数。 The words are separated by a space or numerous spaces. 单词由空格或众多空格分隔。 For example, 例如,

fish duck     cheese            bacon

would return 4. Is there a simple command for that that I'm missing? 将返回4.是否有一个简单的命令,我错过了?

尝试

 $ echo "fish duck     cheese            bacon" | wc -w

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM