This is a job for find
and wc
:
find . -maxdepth 1 -type f -exec wc -w {} \;
This will find
all files (-type f
) in the current working directory (.
), without recursing into subdirectories (-maxdepth 1
) and for each result will execute (-exec [...] \;
) wc -w
passing that filename ({}
) as an argument.
wc
prints the number of newlines, words, and bytes in files by default, -w
specifies it should just print the word-count.