I am looking for a command to count number of all words in a file. For instance if a file is like this,today is a good daythen it should print 5, since there are 5 words there.
how to count total number of words in a file?
text processing;wc
The command wc aka. word count can do it:$ wc -w <file>example$ cat sample.txttoday is a good day$ wc -w sample.txt5 sample.txt# just the number (thanks to Stephane Chazelas' comment)$ wc -w < sample.txt5