Thread: find in system()

  1. #1

    find in system()

    I have a system() call with a find statement in it but i don't want the results printed.

    I know that -print is automatic unless you specify -ok.

    when i do i get errors --->>
    find: 0652-018 An expression term lacks a required parameter.

    system("find . -type d -name \"savedir\" -ok ")

  2. #2
    Registered User
    Join Date
    Dec 2001
    make sure that you are adding the header file #include <stdlib.h> <-- this file is needed to run system commandz

  3. #3
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002

    The problem lies with your use of the -ok switch (-ok requires an argument). The -ok switch will execute another application, just like -exec, but will prompt the user before each execution.

    If you do not want the results of find to be sent to stdout, redirect them:
    system( "find . -type d -name \"savedir\" > /dev/null" );
    Also, the quotation marks around savedir are not necessary, so the following is also valid:
    system( "find . -type d -name savedir > /dev/null" );
    Jason Deckard

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a C Programing Quiz project
    By dilemma in forum C Programming
    Replies: 12
    Last Post: 05-15-2009, 03:35 PM
  2. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  3. Replies: 17
    Last Post: 04-02-2008, 12:09 PM
  4. Replies: 5
    Last Post: 04-16-2004, 01:29 AM
  5. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:50 PM