Regarding the Unix command “wc” what is considered as a word?

拟墨画扇 提交于 2019-12-10 23:08:27

问题


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?


回答1:


This is specified by POSIX:

The wc utility shall consider a word to be a non-zero-length string of characters delimited by white space.

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.



来源:https://stackoverflow.com/questions/48816403/regarding-the-unix-command-wc-what-is-considered-as-a-word

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!