On Tuesday 9 June 2009, 16:36, Neil Bothwick wrote:
> On Tue, 09 Jun 2009 16:15:21 +0200, Joerg Schilling wrote:
> > > find -H /usr/lib /lib -type f | xargs -d'\n' qfile --orphans
> >
> > No, this is definitely wrong: the right way to handle this is
> > execplus (since 19 years).
>
> If it's been around 19 years, why doesn't Google know anything about
> it? What is it?

Well, google does not know everything :)

Basically, using + instead of ; after -exec allows to run the specified 
command less times, each time with the highest possible number of 
arguments (instead of running it once per file, which is what happens 
with ;). And yes, that's been in POSIX for a long time now. Example:


$ ls
file1  file2  file3  file4  file5

$ find . -type f -exec sh -c 'echo "number of arguments: $#"' sh {} \;
number of arguments: 1
number of arguments: 1
number of arguments: 1
number of arguments: 1
number of arguments: 1

$ find . -type f -exec sh -c 'echo "number of arguments: $#"' sh {} +
number of arguments: 5

So when you have to run a command on a very big number of files, say 1000 
or more, with ; you spawn 1000 processes, with + you span just one or 
two (well, depending on the maximum command line length on the system 
anyway). This is of course much less resource intensive.

Basically, using -exec with + does what xargs does, but without the need 
to care for strange characters in file names (well, a bit simplified, 
but you get the idea).

Reply via email to