find: Querying

1 
1 3.3.3 Querying
1 --------------
1 
1 To ask the user whether to execute a command on a single file, you can
1 use the 'find' primary '-okdir' instead of '-execdir', and the 'find'
1 primary '-ok' instead of '-exec':
1 
1  -- Action: -okdir command ;
1      Like '-execdir' (⇒Single File), but ask the user first.  If
1      the user does not agree to run the command, just return false.
1      Otherwise, run it, with standard input redirected from '/dev/null'.
1 
1      The response to the prompt is matched against a pair of regular
1      expressions to determine if it is a yes or no response.  These
1      regular expressions are obtained from the system ('nl_langinfo'
1      items YESEXPR and NOEXPR are used) if the 'POSIXLY_CORRECT'
1      environment variable is set and the system has such patterns
1      available.  Otherwise, 'find''s message translations are used.  In
1      either case, the 'LC_MESSAGES' environment variable will determine
1      the regular expressions used to determine if the answer is
1      affirmative or negative.  The interpretation of the regular
1      expressions themselves will be affected by the environment
1      variables 'LC_CTYPE' (character classes) and 'LC_COLLATE'
1      (character ranges and equivalence classes).
1 
1  -- Action: -ok command ;
1      This insecure variant of the '-okdir' action is specified by POSIX.
1      The main difference is that the command is executed in the
1      directory from which 'find' was invoked, meaning that '{}' is
1      expanded to a relative path starting with the name of one of the
1      starting directories, rather than just the basename of the matched
1      file.  If the command is run, its standard input is redirected from
1      '/dev/null'.
1 
1    When processing multiple files with a single command, to query the
1 user you give 'xargs' the following option.  When using this option, you
1 might find it useful to control the number of files processed per
1 invocation of the command (⇒Limiting Command Size).
1 
1 '--interactive'
1 '-p'
1      Prompt the user about whether to run each command line and read a
1      line from the terminal.  Only run the command line if the response
1      starts with 'y' or 'Y'.  Implies '-t'.
1