关于Unix命令"wc".什么是单词? [英] Regarding the Unix command "wc" what is considered as a word?
问题描述
命令wc
提供lineCount
,wordCount
和charCount
.我正在编写一个模拟wc命令的程序,因为它需要一个文件并吐出3个属性.行数很容易,因为如果它看到\n
,它将为++lineCount
;如果存在一个字符且它不是EOF,则它将为++charCount
.但是单词是什么意思呢?是什么分隔单词,空格?
The command wc
provides lineCount
, wordCount
, and charCount
. I am writing a program that simulates the wc command as it takes a file and spits out the 3 properties. Line count is easy because if it sees \n
it will ++lineCount
and if a char exists and it's not EOF, it will ++charCount
. But what does word mean? What separates words, whitespace?
推荐答案
这是由POSIX指定:
wc 实用程序应将单词视为由空格分隔的非零长度字符串.
The wc utility shall consider a word to be a non-zero-length string of characters delimited by white space.
我的系统(Ubuntu 17.04)上wc
的手册页类似:
The man page for wc
on my system (Ubuntu 17.04) is similar:
单词是由空格分隔的非零长度字符序列.
A word is a non-zero-length sequence of characters delimited by white space.
这篇关于关于Unix命令"wc".什么是单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!