Say I need to find out how many words are in each file that has the word 'work' in its name.
I know that to find files with 'work' in the name, it would be ls work
. And to figure out the number of words in a file it would be wc -w
.
However I tried the following and it seems to be just displaying the number of files, not the number of words combined in all files (which I need):
ls work | wc -w
So say if there are 14 files that have 'work' in the name, it would display 14, not the number of words.