Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > find utility like system call in unix

Reply
Thread Tools

find utility like system call in unix

 
 
rrs.matrix@gmail.com
Guest
Posts: n/a
 
      04-21-2006
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.

 
Reply With Quote
 
 
 
 
Ico
Guest
Posts: n/a
 
      04-21-2006
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
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      04-21-2006
In article <4448c860$0$15047$ l>,
Ico <> 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
 
Reply With Quote
 
SM Ryan
Guest
Posts: n/a
 
      04-21-2006
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Getting the list of mount points on a unix like system Roedy Green Java 1 10-30-2008 09:43 PM
compile C programs with UNIX system calls (= Unix Programs??) jrefactors@hotmail.com C Programming 18 01-10-2005 03:35 AM
compile C programs with UNIX system calls (= Unix Programs??) jrefactors@hotmail.com C++ 12 01-10-2005 03:35 AM
Cisco-like Ping utility for Unix Dan Mahoney Cisco 2 12-27-2003 04:33 AM
s there any C API to find the total VM of a Unix system? Manish Baronia C++ 0 08-19-2003 11:39 AM



Advertisments