find utility like system call in unix

Discussion in 'C Programming' started by rrs.matrix@gmail.com, Apr 21, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Ico Guest

    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
     
    Ico, Apr 21, 2006
    #2
    1. Advertising

  3. In article <4448c860$0$15047$4all.nl>,
    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
     
    Richard Tobin, Apr 21, 2006
    #3
  4. SM Ryan Guest

    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.
     
    SM Ryan, Apr 21, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manish Baronia
    Replies:
    0
    Views:
    327
    Manish Baronia
    Aug 19, 2003
  2. Replies:
    12
    Views:
    1,700
    Dave Thompson
    Jan 10, 2005
  3. markus
    Replies:
    22
    Views:
    682
    Dances With Crows
    Sep 22, 2004
  4. Replies:
    18
    Views:
    656
    Dave Thompson
    Jan 10, 2005
  5. Roedy Green
    Replies:
    1
    Views:
    410
    John W Kennedy
    Oct 30, 2008
Loading...

Share This Page