[X-Unix] question about 'find'

Stewart C. Russell scruss at scruss.com
Mon Nov 28 05:28:26 PST 2005


Eugene wrote:
> 
> Sending the list of filenames to xargs(1) is always nice,
> especially because it is much more efficient and speedier.

You do have to be careful with xargs if you're processing a *lot* of 
arguments. BSD xargs has a default argument limit of 5000 (hidden in the 
'-n' para of the manual), so if you're calling xargs through sort (say), 
the results may not be what you expect.

I think (but could be wrong) that the limit for GNU xargs might be 
different, so cross-platform scripters should be wary. I was going to 
give an example, but OS X doesn't include seq(1), to my dismay.

> However, unlike other flavors, OS X filenames tend to contain
> whitespace characters that break traditional Unix tools  ...

And many others, such as brackets/braces. I assume (hope!) that '/' is 
no longer legal, for it was the scourge of the Solaris-based CAP/AUFS admin.

What's list wisdom on methods of dealing with special characters? I find 
'while' to be a somewhat useful construct, as in:

<command> | while read file
do
  # do something based on $file
done

cheers,
  Stewart



More information about the X-Unix mailing list