On Friday 21 January 2005 18:49, Danny Sauer wrote:
Oh, wait, looking closer... It appears that xargs builds a commandline up until the maximum length on a system, and then runs that.
That is correct.
I always thought that xargs ran a new instance of the exec()'d program for each individual argument. Hmph. I guess that'd explain why it takes 8-10 seconds to do all 2642 files in the samba3 source dir (which was convenient at the time) using -exec, while it only takes about 2 seconds to do the same thing with xargs.
The -exec method is more flexible, though, and will work with programs that only accept one file as an arg, etc. I guess it's just a matter of choosing the right tool for the job, and sinc -exec always works, I tend to go that way. It's easier to remember one thing than 2. :)
You can also use 'xargs -n 1' to execute the command with a single argument at a time. -- Lars Haugseth