[CLUE-Tech] bash and spaces
Dale K. Hawkins
dhawkins at cdrgts.com
Tue Nov 9 16:00:45 MST 2004
Wait. I should read the and grok the question before replying. The
biggest advantage of xargs over -exec is the command is only invoked
once (unless otherwise requested). This can be a significant time
saving if the child process is hefty.
My original message was based on a misunderstanding of the question. I
was trying to answer the wrong question. Some one may still find the
discussion regarding '-0' useful. (And since I wrote it, I am going to
send it anyway, damn it/ :-) )
---
It is really the combination of "find" with the -print0 option in
conjunction with xargs and the -0 option. Essentially, these output
"null" separated strings instead of space separated. This means you
need not worry about the space problem.
$ mkdir example
$ cd example/
$ touch 'space name'
$ find . -type f -print | xargs ls -l
ls: ./space: No such file or directory
ls: name: No such file or directory
$ find . -type f -print0 | xargs -0 ls -l
-rw-r--r-- 1 dhawkins dhawkins 0 2004-11-09 15:50 ./space name
On Tue, 2004-11-09 at 12:58 -0700, Greg Knaddison wrote:
> Dave,
>
> Sorry for being dense. Can you describe why xargs is better than
> exec? I did a little bit of searching but couldn't find anything.
>
> Thanks in advance,
> Greg
>
>
> On Tue, 09 Nov 2004 11:56:26 -0700, David Anselmi <anselmi at anselmi.us> wrote:
> >
> > It's usually better to use xargs with find rather than -exec. Then you
> > can use find's -print0 and xargs's -0 and voila.
> >
> _______________________________________________
> CLUE-Tech mailing list
> Post messages to: CLUE-Tech at clue.denver.co.us
> Unsubscribe or manage your options: http://clue.denver.co.us/mailman/listinfo/clue-tech
More information about the clue-tech
mailing list