wc counts words. And for the purpose of
wc, “a word is a non-zero-length sequence of characters delimited by white space.” Feed
wc a file, and it will happily spit out a total for you.
Except, as you can see, by default
wc gives more than just word counts. It counts newlines, then words, then bytes. Perhaps
wc should be renamed to “nwbc?”
But wait, there’s more:
wc can also total up characters, which may come in handy from time to time.
And as a curiosity,
wc can show the length of the longest line in a file.
kmandla@6m47421: ~/temp$ wc -L output.txt 16 output.txt
I can’t imagine a situation where that would be useful, but I don’t dare argue with a member of the hallowed coreutils package. 😀
So in short,
wc will count newlines, words, bytes, characters and even show the length of the longest line in a file. Is there anything it can’t count?! 😯