> I hate digging up old threads, but I need help on
> this one. It is getting to a stage where I am
> considering leaving the solaris bootcamp and moving
> to something else, more-so because I simply cannot
> find my way around.
> 
> Just to rehash, I am using Indiana, and I need some
> form of file verification tool. md5sum does not work
> recurrently and it seems that passing anything to it
> using xargs or the like has problems with spaces in
> the filenames
> eg: I thought this would work, but doesn't:
> find /maindir/subdir | xargs md5sum
> 
> The main reason for this is spaces in the filename
> and both xargs and find do not support the null
> terminating option found in other distros.

They don't need to - Solaris (and many other SVR4 derived?) find
commands have long had a relatively recently documented shortcut
that accomplishes much of what the -print0 and -0 of the GNU tools do.

Instead of

find /path -exec prog {} \;

use

find /path -exec prog {} +

That is, terminate it with a plus sign rather than a quoted or escaped 
semicolon.
That causes find to run prog less times, with multiple arguments, and it
safely handles spaces and all that.  The only limit is that if you do that, the
{} must be the last (or only) argument to the program.

Reasonably new versions of the man page describe this:

> -exec command
>    True if the executed command returns a zero value as exit status. The
>    end of command must be punctuated by an escaped semicolon (;).
>    A command argument {} is replaced by the current pathname.
>    If the last argument to -exec is {} and you specify + rather than the
>    semicolon (;), the command is invoked fewer times, with {} replaced by
>    groups of pathnames. If any invocation of the command returns a non-zero
>    value as exit status, find returns a non-zero exit status.

In fact, this feature has found its way into standards (SUSv3) even:
http://www.opengroup.org/onlinepubs/000095399/utilities/find.html

And newer versions of GNU find can do it (along with way too much other stuff)
too:
http://www.gnu.org/software/findutils/manual/html_mono/find.html#Multiple-Files
 
 
This message posted from opensolaris.org

Reply via email to