Next: Limiting Command Size, Previous: Safe File Name Handling, Up: Multiple Files
As discussed above, you often need to be careful about how the names
of files are handled by find
and other programs. If the output
of find
is not going to another program but instead is being
shown on a terminal, this can still be a problem. For example, some
character sequences can reprogram the function keys on some terminals.
See Security Considerations, for a discussion of other security
problems relating to find
.
Unusual characters are handled differently by various actions, as described below.
This quoting is performed in the same way as for GNU ls
. This
is not the same quoting mechanism as the one used for ‘-ls’ and
‘fls’. If you are able to decide what format to use for the
output of find
then it is normally better to use ‘\0’ as a
terminator than to use newline, as file names can contain white space
and newline characters.
find
in a
script or in a situation where the matched files might have arbitrary
names, you should consider using ‘-print0’ instead of
‘-print’.
The locate
program quotes and escapes unusual characters in
file names in the same way as find
's ‘-print’ action.
The behaviours described above may change soon, as the treatment of unprintable characters is harmonised for ‘-ls’, ‘-fls’, ‘-print’, ‘-fprint’, ‘-printf’ and ‘-fprintf’.