From: * Tong * on
On Tue, 05 Dec 2006 22:25:32 +0000, Stephane CHAZELAS wrote:

>> May I ask why the 1st command fails?
>
> As Michael pointed out, + must follow {}.

Ops, just missed it. thank you both.

So basically {} has to be at the end, not like in xargs where it could be
anywhere...

--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/


--
Posted via a free Usenet account from http://www.teranews.com

From: * Tong * on
On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote:

> find /other/path ! -group grp -exec sh -c '
> exec ln -s "$@" dest' arg0 {} +

what the arg0 here for?

(didn't find in 'find' man page.)

--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/


--
Posted via a free Usenet account from http://www.teranews.com

From: Barry Margolin on
In article <pan.2006.12.05.23.23.29.361706(a)users.sourceforge.net>,
* Tong * <sun_tong_001(a)users.sourceforge.net> wrote:

> On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote:
>
> > find /other/path ! -group grp -exec sh -c '
> > exec ln -s "$@" dest' arg0 {} +
>
> what the arg0 here for?

When using the -c option to the shell, the first argument after the
command string is used as the shell's $0, and the remaining ones fill in
$@. So you need a dummy argument to fill in $0.

A better question would be what the exec is for. Most shells
automatically exec the last (in this case only) command, kind of like
tail-call elimination in Scheme. Notice:

barmar $ sh -c 'sleep 100' &
[1] 6370
barmar $ ps -p 6370
PID TT STAT TIME COMMAND
6370 p1 S 0:00.02 sleep 100


>
> (didn't find in 'find' man page.)

Why would you expect to find documentation of a sh argument in find's
man page?

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Stephane CHAZELAS on
2006-12-05, 21:48(-05), Barry Margolin:
> In article <pan.2006.12.05.23.23.29.361706(a)users.sourceforge.net>,
> * Tong * <sun_tong_001(a)users.sourceforge.net> wrote:
>
>> On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote:
>>
>> > find /other/path ! -group grp -exec sh -c '
>> > exec ln -s "$@" dest' arg0 {} +
>>
>> what the arg0 here for?
>
> When using the -c option to the shell, the first argument after the
> command string is used as the shell's $0, and the remaining ones fill in
> $@. So you need a dummy argument to fill in $0.
>
> A better question would be what the exec is for. Most shells
> automatically exec the last (in this case only) command, kind of like
> tail-call elimination in Scheme. Notice:

ash and pdksh based shells don't, AT&T ksh, bash and zsh based
ones do.

If you've got traps set up, that optimisation becomes a bug,
such as in AT&T ksh. bash and zsh know not to do that
optimisation when there are traps.

--
St�phane