yyy@xxxxxxxxxxx (Geoff Clare) writes,
> I would like to suggest an addition to the standard to address the
> common problem of how to handle special characters in filenames
> when using find and xargs together. ...
>
> I know of two existing solutions to the problem. One is the GNU
> extension:
>
> find . -type f -print0 | xargs -0 some_command
>
> which causes find to output null-terminated pathnames instead of
> newline-terminated ones, and causes xargs to read in null-terminated
> pathnames and to turn off its special handling of backslash and quotes.
I would like to suggest something that is less common but seems a
little more useful to me. A couple of years ago I submitted a patch
to NetBSD to add a new "-printx" flag to the find command. Like
print0, it generates output in a format that xargs can use safely,
but unlike print0, it works just by adding a backslash before every
space, tab, apostrophe, quote, newline, or backslash. The advantage
I see to doing it this way is that the output can still be processed
by other filters, unlike text with NUL terminated lines, which is
basically suitable only for handing directly to xargs.
Eric Fischer
yyy@xxxxxxxxx
|