mirror of
git://git.sv.gnu.org/findutils.git
synced 2026-01-31 21:58:58 +01:00
Applied Dmitry's patch for -okdir and -execdir actions
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2005-06-18 Dmitry V. Levin <ldv@altlinux.org>
|
||||
|
||||
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 <patch-findutils.buzz@bavag.tmfweb.nl>
|
||||
|
||||
* locate/locate.c: Implement --all (-A).
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <bug-findutils@gnu.org>."));
|
||||
|
||||
Reference in New Issue
Block a user