Find the largest C/C++ source files in all subdirectories

find . -name '*.c*' -o -name '*.h' -exec wc -l {} \; | sort -n | tail
This is helpful when approaching a new codebase and wondering where the bulk of the code is located
Sample Output
user@ubuntu:~/downloads/linux-4.3$ find . -name '*.c*' -o -name '*.h' -exec wc -l {} \; | sort -n | tail
13109 ./drivers/gpu/drm/amd/include/asic_reg/dce/dce_8_0_sh_mask.h
14416 ./drivers/gpu/drm/amd/include/asic_reg/gmc/gmc_7_1_sh_mask.h
15055 ./drivers/media/dvb-frontends/drx39xyj/drxj_map.h
15682 ./drivers/gpu/drm/amd/include/asic_reg/gmc/gmc_8_1_sh_mask.h
16647 ./drivers/gpu/drm/amd/include/asic_reg/dce/dce_10_0_sh_mask.h
17557 ./drivers/gpu/drm/amd/include/asic_reg/dce/dce_11_0_sh_mask.h
18444 ./drivers/gpu/drm/amd/include/asic_reg/gca/gfx_7_2_sh_mask.h
20776 ./drivers/gpu/drm/amd/include/asic_reg/gca/gfx_8_0_sh_mask.h
33080 ./drivers/gpu/drm/amd/include/asic_reg/bif/bif_5_1_sh_mask.h
33595 ./crypto/testmgr.h

0
2015-12-02 00:30:42

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: