Re: shell game
On Sun, Dec 08, 2002 at 12:31:30AM -0600, Michael Heironimus wrote:
> On Sat, Dec 07, 2002 at 08:26:21PM +0100, Frank Gevaerts wrote:
> > > find . -name '*.jpg' -print0 | xargs -r0 mpg123
> >
> > Any special reason not to use -exec (except of course that xargs works
> > with any input, while -exec only with find (obviously))
>
> I always use xargs instead of find -exec because it just comes more
> naturally to me. There are some technical reasons for it, though.
I guess the most important reason is that xargs can combine arguments,
so it calls the command less often. Since I mostly use find/exec/xargs
for commands that can take only one filename, I didn;'t think of this
immediately.
> GNU xargs is considerably more versatile than -exec. On some platforms
> (not sure about GNU find/xargs) find also spawns a subshell for every
> file with -exec, which makes xargs considerably more efficient. Not much
> difference for a dozen files, but if you have a few thousand results
> you're saving the time of starting a few thousand shells that do nothing
> but run a single command and exit.
I didn't know about this. I might checxk on the GNU find behaviour some
day.
Frank
>
> --
> Michael Heironimus
>
>
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: