Monday, 30 September 2013

How do I list word count in multiple files?

How do I list word count in multiple files?

Say I need to find out how many words are in each file that have the word
'work' in it.
I know that to find files with 'work' in it, it would be ls work. And to
figure out the number of words it would be wc -w
However I tried this 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 follow the 'work' prereq, it would
display 14, not the number of words.

No comments:

Post a Comment