16

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

2 Answers 2

25
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 :)

1
  • 1
    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, 2011 at 16:33
6

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".

You must log in to answer this question.

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