开发者

how to let wc command recursivly? [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

开发者_Python百科 Improve this question

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


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


bash 4

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


I think find and xargs is clearer and easier to work with instead of find -exec but it's style choice.

find . -name "*.h" -or -name "*.cpp" | xargs wc


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜