find utility like system call in unix

R

rrs.matrix

hi

is there any system call in unix that will search for a file in the
filesystem.
someting like the find utility.

if not then how should i search for a file in the file system.
heard of system call by name opendir and readdir - is the how it should
be done.
tx.
 
I

Ico

is there any system call in unix that will search for a file in the
filesystem. someting like the find utility.

A newsgroup discussing unix would probably be a better place to ask this
question. iirc, there is no such function call in any of the unixes I
know, but there might be in other flavours.
if not then how should i search for a file in the file system. heard
of system call by name opendir and readdir - is the how it should be
done.

Yes, with unix these functions are probably the way to go. Think
'recursion'. The find utility probably relies on those functions as
well. Note that these functions are defined by Posix, and not part of
standard ANSI C.

tx ?
 
R

Richard Tobin

A newsgroup discussing unix would probably be a better place to ask this
question. iirc, there is no such function call in any of the unixes I
know, but there might be in other flavours.

Some unixes have a function "ftw" or functions with names beginning
"fts" that do this sort of thing. According to one manual page, "the
fts utility is expected to be included in a future IEEE Std
1003.1-1988 (POSIX.1) revision", so you might look for a Posix-related
group or web site.

-- Richard
 
S

SM Ryan

(e-mail address removed) wrote:
# hi
#
# is there any system call in unix that will search for a file in the
# filesystem.
# someting like the find utility.

You can do most any command line with something like
system("find /usr/local -name '*mysql*' >find-output");
FILE *f = fopen("find-output","r");
...
fclose(f);

If you're willing to restrict yourself to Posix, you can do something like
FILE *f = popen("find /usr/local -name '*mysql*' >find-output","r");
...
pclose(f);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top