1833192 Members
2749 Online
110051 Solutions
New Discussion

Unix Program for find

 
girishb
Frequent Advisor

Unix Program for find

Hello Folks,

I need to write Unix C sytem program to find all the files with the given filename under a given subdirectory.The files to be found can be in arbitary depth in the directory tree.

The output should be the same as that of command "find"(i.e the path to the file will be printed out)

Please help!!

Thanks
Girish
2 REPLIES 2
Steven Schweda
Honored Contributor

Re: Unix Program for find

> I need to write [...]

Why? Is there some actual problem which you
are trying to solve?

> The output should be the same as that of
> command "find"

system( "find [...]");


If you really need a C program, I believe
that it's been done already:

http://www.gnu.org/software/findutils/
Dennis Handly
Acclaimed Contributor

Re: Unix Program for find

>Steven: If you really need a C program, I believe that it's been done already:

You can also use ftw(3). If you need pattern matching, you can use fnmatch(3).