PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > find: missing argument to `-exec'
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

find: missing argument to `-exec'

Réponse
 
LinkBack Outils de la discussion
Vieux 05/12/2006, 19h35   #1
* Tong *
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut find: missing argument to `-exec'

Hi,

I get "find: missing argument to `-exec'" for the following command but I
don't know how to fix:

find /other/path ! -group grp -exec ln -s {} dest +

please . thanks

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


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

  Réponse avec citation
Vieux 05/12/2006, 20h10   #2
Michael Tosch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

* Tong * wrote:
> Hi,
>
> I get "find: missing argument to `-exec'" for the following command but I
> don't know how to fix:
>
> find /other/path ! -group grp -exec ln -s {} dest +
>
> please . thanks
>


Most implementations of + require it to immediately follow the {}
Otherwise, use \; rather than +

You have another problem with the ln command and the static "dest":
if find finds two or more files, you will get a "file exists" error.

--
Michael Tosch @ hp : com
  Réponse avec citation
Vieux 05/12/2006, 20h16   #3
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

2006-12-05, 21:10(+01), Michael Tosch:
> * Tong * wrote:
>> Hi,
>>
>> I get "find: missing argument to `-exec'" for the following command but I
>> don't know how to fix:
>>
>> find /other/path ! -group grp -exec ln -s {} dest +
>>
>> please . thanks
>>

>
> Most implementations of + require it to immediately follow the {}
> Otherwise, use \; rather than +
>
> You have another problem with the ln command and the static "dest":
> if find finds two or more files, you will get a "file exists" error.

[...]

I think "dest" above is a directory, so you'll get trouble only
if find finds two files having the same name.

To answer the OP's question

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

--
Stéphane
  Réponse avec citation
Vieux 05/12/2006, 22h15   #4
* Tong *
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote:

>>> I get "find: missing argument to `-exec'" for the following command but I
>>> don't know how to fix:
>>>
>>> find /other/path ! -group grp -exec ln -s {} dest +

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


Thanks for your answers, Stephane.

May I ask why the 1st command fails?

I tried and succeeded with the following command, which looks not much
different than the 1st one:

find /other/path ! -group grp -exec chgrp arch {} +

why? thanks

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


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

  Réponse avec citation
Vieux 05/12/2006, 22h25   #5
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

2006-12-05, 17:15(-05), * Tong *:
> On Tue, 05 Dec 2006 20:16:57 +0000, Stephane CHAZELAS wrote:
>
>>>> I get "find: missing argument to `-exec'" for the following command but I
>>>> don't know how to fix:
>>>>
>>>> find /other/path ! -group grp -exec ln -s {} dest +

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

>
> Thanks for your answers, Stephane.
>
> May I ask why the 1st command fails?

[...]

As Michael pointed out, + must follow {}.

See
http://www.opengroup.org/onlinepubs/...ties/find.html

--
Stéphane
  Réponse avec citation
Vieux 05/12/2006, 23h17   #6
* Tong *
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

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

  Réponse avec citation
Vieux 05/12/2006, 23h23   #7
* Tong *
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

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

  Réponse avec citation
Vieux 06/12/2006, 02h48   #8
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

In article <pan.2006.12.05.23.23.29.361706@users.sourceforge. net>,
* Tong * <sun_tong_001@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@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 ***
  Réponse avec citation
Vieux 06/12/2006, 08h52   #9
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find: missing argument to `-exec'

2006-12-05, 21:48(-05), Barry Margolin:
> In article <pan.2006.12.05.23.23.29.361706@users.sourceforge. net>,
> * Tong * <sun_tong_001@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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h53.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16221 seconds with 17 queries