I have said that actions are those which actually do something. Well, -prune rather does not do something, i.e. descending the directory tree (unless -depth is given). It is usally find together with -fstype, to choose among the various filesystems which should be checked.
The other actions can be divided into two broad categories;
-exec command \;
the command is executed, and the
action returns true if its final status is 0, that is regular execution
of it. The reason for the \;
is rather logical: find
does not know where the command ends, and the trick to put the exec
action at the end of the command is not applicable. Well, the best way
to signal the end of the command is to use the character used to do this
by the shell itself, that is `;', but of course a semicolon all
alone on the command line would be eaten by the shell and never sent to
find, so it has to be escaped. The second thing to remember is how
to specify the name of the current file within command, as
probably you did all the trouble to build the expression to do
something, and not just to print date. This is done by means of the
string {}
. Some old versions of find require that it must
be embedded in white space - not very handy if you needed for example
the whole path and not just the file name - but with GNU find could be
anywhere in the string composing command. And shouldn't it be
escaped or quoted, you surely are asking? Amazingly, I never had to do
this neither under tcsh nor under bash (sh does not consider {
and
}
as special characters, so it is not much of a problem). My idea
is that the shells ``know'' that {}
is not an option making sense,
so they do not try to expand them, luckily for find which can obtain
it untouched.
-ok command \;
behaves like -exec, with the
difference that for each selected file the user is asked to confirm the
command; if the answer starts with y or Y, it is executed,
otherwise not, and the action returns false.