bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems and suggestion for "find ... -printf ..."


From: lukekendall
Subject: Problems and suggestion for "find ... -printf ..."
Date: Tue, 2 Oct 2001 22:28:11 +1000 (EST)

In the course of changing over from using "fls" (which I suspect is a
command line utility like GNU stat), to using find's -printf argument
to achieve the same effect, I came upon two problems.

The first is very small: although the man page says that \-escape
sequences that -printf doesn't understand are passed through unaltered
(good!), find in fact issues a warning message about unrecognised escape
sequences (bad).

E.g. try this:


find "/etc/skel/Desktop/Linux Documentation" -prune -printf 
"FILE=/etc/skel/Desktop/Linux\ Documentation; my_command"
find: warning: unrecognized escape `\ '


The second problem is that if you want the output of the -printf to be
shell commands for input to some other shell process later, e.g.:

        find "/$DIR" -type l -printf "cd '%h' && ln -s '%l' '%p'\n"

then you really need to have format options for the filename formats
that output \-escaped filenames.  The above command will work for
filenames with spaces, for example, but if the filename contains
single-quote characters then the commands won't execute properly in the
follow-on shell.


Maybe %\%h, %\%l and %\%p would be reasonable choices; %\ is not
otherwise meaningful, and it does suggest backslash-escaping of the
subject.

Regards,

luke




reply via email to

[Prev in Thread] Current Thread [Next in Thread]