tags:

views:

41

answers:

3

Let it counting *.h *.cpp in Sub directory.

+4  A: 

If you want it seperate per file:

find -type f \( -name "*.h" -o -name "*.cpp" \) -exec wc {} \;

if you want the accumulated sum:

find -type f \( -name "*.h" -o -name "*.cpp" \) -exec cat {} \; | wc -l
theomega
A: 

Use zsh instead of bash:

wc **/*.(cpp|h)

This will expand out to all the .cpp and .h files in the current directory and all subdirectories.

Dave Kirby
A: 

bash 4

shopt -s globstar
wc **/*.{cpp,h}
ghostdog74