Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Could someone please help me to find all the *.c and *.h files in a directory tree??

share|improve this question
up vote 11 down vote accepted
find . -name '*.[ch]' -type f 

*.[ch] represents all *.h and *.c files, -type f finds regular files.

P.S. You might want to accept answers for your other questions :)

share|improve this answer
it is works for me :) but why you said You might want to accept answers for your other questions..I couldnt get it ..maybe my english is not good enough. – Eli Sep 29 '11 at 16:33

If you are at the top of the directory tree.

find . -name *.c -print

would find all the .c files located below the current "." directory.

Lot's more help can be find by searching "unix find command".

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .