By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,153 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

find utility like system call in unix

P: n/a
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.

Apr 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ico
rr********@gmail.com wrote:

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.


tx ?
--
:wq
^X^Cy^K^X^C^C^C^C
Apr 21 '06 #2

P: n/a
In article <44***********************@dreader18.news.xs4all.n l>,
Ico <us****@zevv.nl> wrote:
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.


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
Apr 21 '06 #3

P: n/a
rr********@gmail.com 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);

--
SM Ryan http://www.rawbw.com/~wyrmwif/
This is one wacky game show.
Apr 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.