diff --git a/ChangeLog b/ChangeLog index f9d24080..e47c44d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-06-18 Dmitry V. Levin + + Additional documentation tweaks for -execdir/-okdir actions. + * find/parser.c (parse_help): Mention -execdir and -ordir options. + * doc/find.texi, find/find.1: Additionally document new options. + 2005-06-12 Bas van Gompel * locate/locate.c: Implement --all (-A). diff --git a/doc/find.texi b/doc/find.texi index 1a65af67..b23d4a56 100644 --- a/doc/find.texi +++ b/doc/find.texi @@ -2015,10 +2015,10 @@ find bills -type f | xargs -iXX sort -o XX.sorted XX @end example @noindent -The equivalent command using @samp{find -exec} is: +The equivalent command using @samp{find -execdir} is: @example -find bills -type f -exec sort -o '@{@}.sorted' '@{@}' ';' +find bills -type f -execdir sort -o '@{@}.sorted' '@{@}' ';' @end example @end table @@ -2026,14 +2026,24 @@ find bills -type f -exec sort -o '@{@}.sorted' '@{@}' ';' @subsection Querying To ask the user whether to execute a command on a single file, you can -use the @code{find} primary @samp{-ok} instead of @samp{-exec}: +use the @code{find} primary @samp{-okdir} instead of @samp{-execdir}, +and the @code{find} primary @samp{-ok} instead of @samp{-exec}: -@deffn Action -ok command ; -Like @samp{-exec} (@pxref{Single File}), but ask the user first (on +@deffn Action -okdir command ; +Like @samp{-execdir} (@pxref{Single File}), but ask the user first (on the standard input); if the response does not start with @samp{y} or @samp{Y}, do not run the command, and return false. @end deffn +@deffn Action -ok command ; +This insecure variant of the @samp{-okdir} action is specified by +POSIX. The main difference is that the command is executed in the +directory from which @code{find} was invoked, meaning that @samp{@{@}} +is expanded to a relative path starting with the name of one of the +starting directories, rather than just the basename of the matched +file. +@end deffn + When processing multiple files with a single command, to query the user you give @code{xargs} the following option. When using this option, you might find it useful to control the number of files processed per @@ -2306,7 +2316,7 @@ the file name contains a character with the high bit set; the shell may strip it off. A more reliable way is: @example -find . -maxdepth 1 @var{tests} -ok rm '@{@}' \; +find . -maxdepth 1 @var{tests} -okdir rm '@{@}' \; @end example @noindent @@ -2325,18 +2335,18 @@ have found that its inode number is 12345. This command prompts you for whether to remove it: @example -find . -maxdepth 1 -inum 12345 -ok rm -f '@{@}' \; +find . -maxdepth 1 -inum 12345 -okdir rm -f '@{@}' \; @end example If you don't want to be asked, perhaps because the file name may contain a strange character sequence that will mess up your screen when printed, -then use @samp{-exec} instead of @samp{-ok}. +then use @samp{-execdir} instead of @samp{-okdir}. If you want to rename the file instead, you can use @code{mv} instead of @code{rm}: @example -find . -maxdepth 1 -inum 12345 -ok mv '@{@}' @var{new-file-name} \; +find . -maxdepth 1 -inum 12345 -okdir mv '@{@}' @var{new-file-name} \; @end example @node Fixing Permissions diff --git a/find/find.1 b/find/find.1 index b61103d2..fa7fe107 100644 --- a/find/find.1 +++ b/find/find.1 @@ -993,7 +993,7 @@ Determines the locale to be used for internationalised messages. Determines the location of the internationalisation message catalogues. .IP PATH Affects the directories which are searched to find the executables -invoked by `\-exec' and `\-ok'. +invoked by `\-exec', `\-execdir', `\-ok' and `\-okdir'. .IP POSIXLY_CORRECT Determines the block size used by `-ls'. .IP TZ diff --git a/find/parser.c b/find/parser.c index 3c8bab34..09020fc6 100644 --- a/find/parser.c +++ b/find/parser.c @@ -756,9 +756,11 @@ tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N\n\ -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n\ -used N -user NAME -xtype [bcdpfls]\n")); puts (_("\ -actions: -exec COMMAND ; -fprint FILE -fprint0 FILE -fprintf FILE FORMAT\n\ - -fls FILE -ok COMMAND ; -print -print0 -printf FORMAT -prune -ls -delete\n\ - -quit\n")); +actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print \n\ + -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit\n\ + -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;\n\ + -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;\n\ +")); puts (_("Report (and track progress on fixing) bugs via the findutils bug-reporting\n\ page at http://savannah.gnu.org/ or, if you have no web access, by sending\n\ email to ."));